﻿#include "PluginPHengLEIExtend.h"
class IOConfigure;
#include <QDebug>
#include "mainWindow/mainWindow.h"
#include "ModelData/modelDataFactory.h"
#include "ModelData/modelDataSingleton.h"
#include "ModelData/modelDataBase.h"
#include "IO/IOConfig.h"
#include <QDir>
#include <QApplication>
#include <QFile>
#include <QTextCodec>
#include "MeshData/meshSingleton.h"
#include "MeshData/meshSet.h"
#include "PluginMeshDataExchange/MeshThreadBase.h"
#include <QTextStream>
#include <QTextCodec>
#include "IO/SolverIO.h"
#include <QtMath>
#include <QMessageBox>
#include <QDataStream>
#include "DataProperty/ParameterPath.h"
#include "BCBase/BCBase.h"
#include "ConfigOptions/ConfigOptions.h"
#include "ConfigOptions/SolverConfig.h"
#include "ConfigOptions/SolverInfo.h"


namespace GUI
{
    class MainWindow;
}

namespace Plugins
{
    PluginPHengLEIExtend::PluginPHengLEIExtend(GUI::MainWindow* m)
    {
        mMainWindow = m;
        _describe = "PHengLEI plugin";
    }

    bool PluginPHengLEIExtend::install()
    {
        IO::IOConfigure::RegisterInputFile("PHengLEIRollDamp", WriteOut);
        IO::IOConfigure::RegisterOutputTransfer("PHengLEIFileTrans", transfer);

        return true;
    }

    bool PluginPHengLEIExtend::uninstall()
    {
        IO::IOConfigure::RemoveInputFile("PHengLEIRollDamp");
        IO::IOConfigure::RemoveInputFile("PHengLEIFileTrans");
        return true;
    }

    GUI::MainWindow* PluginPHengLEIExtend::getMainWindow()
    {
        return mMainWindow;
    }
}

void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* plugph)
{
    Plugins::PluginBase* p = new Plugins::PluginPHengLEIExtend(m);
    plugph->append(p);
}


bool PHENGLEIPLUGINAPI copyGridFiles(const QString& fromDir, const QString& toDir, bool coverFileIfExist)
{
    QDir sourceDir(fromDir);
    QDir targetDir(toDir);
    if (!targetDir.exists()) {    /**< 如果目标目录不存在，则进行创建 */
        if (!targetDir.mkdir(targetDir.absolutePath()))
            return false;
    }
    QFileInfoList fileInfoList = sourceDir.entryInfoList();
    foreach(QFileInfo fileInfo, fileInfoList) {
        if (fileInfo.fileName() == "." || fileInfo.fileName() == "..")
            continue;
        if (fileInfo.isDir())
        {    /**< 当为目录时，递归的进行copy */
            if (!copyGridFiles(fileInfo.filePath(),
                targetDir.filePath(fileInfo.fileName()), coverFileIfExist))
                return false;
        }
        else {            /**< 当允许覆盖操作时，将旧文件进行删除操作 */

            if (coverFileIfExist && targetDir.exists(fileInfo.fileName())) {
                targetDir.remove(fileInfo.fileName());
            }
            /// 进行文件copy
            if (!QFile::copy(fileInfo.filePath(),
                targetDir.filePath(fileInfo.fileName()))) {
                return false;
            }
        }

    }
    return true;
}

bool WriteOut(QString pathPH, ModelData::ModelDataBase* d)
{
    transfer(pathPH);
    QString fileName;
    QString casePath;
    
    casePath = d->getPath() + "/";
    qDebug() << d->getName();
    qDebug() << "writeTest";
    QDir dir;

    //1. 创建bin和grid文件目录
    QString resultpath;
    
    resultpath = casePath + "bin/";
    if (!dir.exists(resultpath))
    {
        bool res = dir.mkpath(resultpath);
    }
    
    resultpath = casePath + "grid/";
    if (!dir.exists(resultpath))
    {
        bool res = dir.mkpath(resultpath);
    }
    
    // 2. 拷贝网格文件，拷贝风雷默认配置文件

    QDir* createfile = new QDir;

    qDebug() << createfile->currentPath();
    qDebug() << casePath + "../../mesh.msh";
    qDebug() << casePath + "grid/mesh.msh";
    QString oldPath = createfile->currentPath() + "/mesh.msh";
    QFile::copy(oldPath , casePath + "grid/mesh.msh");
    ConfigOption::SolverOption* solvers = ConfigOption::ConfigOption::getInstance()->getSolverOption();
    ConfigOption::SolverInfo* solverInfo = solvers->getSolverAt(0);
    qDebug() << "PHengLEI solver path : " + solverInfo->getExePath();
    QString releasePath = solverInfo->getExePath();
    releasePath.replace("/Release/PHengLEIv3d0.exe", "/Release/");

    QString binPath = createfile->currentPath() + "/bin/";
    QString gridPath = createfile->currentPath() + "/grid/";
    QDir* moveMesh = new QDir;
    if (!moveMesh->exists(binPath))
    {
        bool res = moveMesh->mkpath(binPath);
    }
    if (!moveMesh->exists(gridPath))
    {
        bool res = moveMesh->mkpath(gridPath);
    }
    QString oldMeshPath = moveMesh->currentPath() + "/mesh.msh";
    QString newMeshPath = gridPath + "/mesh.msh";
    if (moveMesh->exists(newMeshPath))
    {
        moveMesh->remove(newMeshPath);
    } 
    if (dir.exists(gridPath + "mesh_0.bcmesh"))
    {
        dir.remove(gridPath + "mesh_0.bcmesh");
    }
    if (dir.exists(gridPath + "mesh_0.bcname"))
    {
        dir.remove(gridPath + "mesh_0.bcname");
    }
    if (dir.exists(gridPath + "mesh_0.fts"))
    {
        dir.remove(gridPath + "mesh_0.fts");
    }
    QFile::copy(oldMeshPath, newMeshPath);

    //  3. 开始文件信息写入
    if (!writeinputText((casePath + "bin/" + "key.hypara"), d))
    {
        return false;
    }
    if (!writeinputText((casePath + "bin/" + "cfd_para_incompressible.hypara"), d))
    {
        return false;
    }
    if (!writeinputText((casePath + "bin/" + "grid_para.hypara"), d))
    {
        return false;
    }
    if (!writeinputText((casePath + "bin/" + "cfd_para.hypara"), d))
    {
        return false;
    }
    if (!writeinputText((binPath + "key.hypara"), d))
    {
        return false;
    }
    if (!writeinputText((binPath + "grid_para.hypara"), d))
    {
        return false;
    }
    QFile::copy((casePath + "bin/" + "cfd_para.hypara"), (binPath + "cfd_para.hypara"));
    qDebug() << solverInfo->getExePath().toLocal8Bit();
    WinExec((LPCSTR)(solverInfo->getExePath().toLocal8Bit()), SW_HIDE);

    int i = 1;
    while (!dir.exists(gridPath + "mesh_0.fts"))
    {
        Sleep(1000);
        i += 1;
        if (i > 10000)
        {
            qDebug() << "error";
            return 0;
        }
    }

    if (dir.exists(resultpath+"mesh.msh"))
    {
        dir.remove(resultpath + "mesh.msh");
    }
    if (dir.exists(resultpath + "mesh_0.bcmesh"))
    {
        dir.remove(resultpath + "mesh_0.bcmesh");
    }
    if (dir.exists(resultpath + "mesh_0.bcname"))
    {
        dir.remove(resultpath + "mesh_0.bcname");
    }
    if (dir.exists(resultpath + "mesh_0.fts"))
    {
        dir.remove(resultpath + "mesh_0.fts");
    }
    if (dir.exists(casePath + "bin/" + "boundary_condition.hypara"))
    {
        dir.remove(casePath + "bin/" + "boundary_condition.hypara");
    }
    QFile::copy(gridPath + "mesh.msh", resultpath + "mesh.msh");
    QFile::copy(gridPath + "mesh_0.bcmesh", resultpath + "mesh_0.bcmesh");
    QFile::copy(gridPath + "mesh_0.bcname", resultpath + "mesh_0.bcname");
    QFile::copy(gridPath + "mesh_0.fts", resultpath + "mesh_0.fts");
    QFile::copy(binPath + "boundary_condition.hypara", casePath + "bin/" + "boundary_condition.hypara");
    
    // 4. 转化网格后对边界条件文件进行改写
    QString boundaryFilePath = casePath + "bin/" + "boundary_condition.hypara";
    QFileInfo file(boundaryFilePath);
    if (file.exists())
    {
        if (!BCOperation( d, boundaryFilePath) )
        {
            return false;
        }
    }
    

    return true;
}

bool transfer(QString path)
{
    // 待转换result path
    qDebug() << path;
    //QString resultPltPath = path + "/results/tecflow100.plt";
    //QString resultszPltPath = path + "/results/tecflow100.szplt";

    std::vector<std::string> fileNames;
    GetFiles(path.toStdString()+"/results/", fileNames);

    std::string suffix = ".plt";
    std::string suffix_wrong = ".bak";
    std::string prefix = path.toStdString() + "/results/tecflow";

    int maxPlot = -1;

    if (fileNames.size() > 0)
    {
        for (int iFile = 0; iFile < fileNames.size(); ++iFile)
        {

            std::string::size_type flag1 = fileNames[iFile].find(suffix);
            std::string::size_type flag2 = fileNames[iFile].find(suffix_wrong);
            if (flag1 != std::string::npos && flag2 == std::string::npos)
            {
                std::string pltName = fileNames[iFile];
                int m = pltName.find(suffix);
                pltName.erase(m, suffix.size());
                m = pltName.find(prefix);
                pltName.erase(m, prefix.size());
                if (atoi(pltName.c_str()) > maxPlot)
                {
                    maxPlot = atoi(pltName.c_str());
                }
            }
        }
    }

    QString resultPltPath = path + "/results/tecflow" + QString::fromStdString(std::to_string(maxPlot))+ ".plt";
    QString resultszPltPath = path + "/results/tecflow" + QString::fromStdString(std::to_string(maxPlot)) + ".szplt";

    // 配置 转换 exe path
    ConfigOption::SolverOption* solvers = ConfigOption::ConfigOption::getInstance()->getSolverOption();
    ConfigOption::SolverInfo* solverInfo = solvers->getSolverAt(0);
    QString releasePath = solverInfo->getExePath();
    releasePath.replace("/Release/PHengLEIv3d0.exe", "/Release/dattoplt.exe");

    QString exeucePath = releasePath + " " + resultPltPath + " " + resultszPltPath;
    qDebug() << exeucePath;
    WinExec((LPCSTR)(exeucePath.toLocal8Bit()), SW_SHOW);
    return true;
}

void PHENGLEIPLUGINAPI sendMessageToConsole(QString hintInfo)
{

}

bool PHENGLEIPLUGINAPI writeinputText(QString filename, ModelData::ModelDataBase*d)
{
    QString paraValue;
    QString paraType;
    QStringList paraList;

    QString casePath = d->getPath() + "/";
    QString resultpath = casePath + "bin/";
    QString solverPath = ConfigOption::ConfigOption::getInstance()->getSolverOption()->getSolverAt(0)->getExePath();  
    QDir* createfile = new QDir;
    QString binPath = createfile->currentPath()+"/bin/";


    QString splitLine = "///////////////////////////////////////////////////////////////////////////////////";

    int nVisualVariables = 4;
    

    if (filename == (resultpath + "key.hypara"))
    {
        //key文件生成
        paraList.append("string title = \"PHengLEI Main Parameter Control File\"");
        paraList.append("string defaultParaFile = \"./bin/cfd_para.hypara\"");
        paraList.append("int nparafile = 1");
        paraList.append("int numberOfGridProcessor = 0");
        paraList.append("int iovrlap = 0");
        paraList.append("int nsimutask = 0");
        paraList.append("string parafilename = \"./bin/cfd_para_incompressible.hypara\"");


        DataProperty::ParameterSelectable* ndim = getParameterSelectable(QStringLiteral("ndim"), d);
        QString ndimA[2] = { "3","2" };
        int paraIndex = ndim->getCurrentIndex();
        paraValue = ndimA[paraIndex];
        paraList.append("int " + QStringLiteral("ndim%1%2").arg(" = ").arg(paraValue));

    }
    else if (filename == (binPath + "key.hypara"))
    {
        paraList.append("string title = \"PHengLEI Main Parameter Control File\"");
        paraList.append("string defaultParaFile = \"./bin/cfd_para.hypara\"");
        paraList.append("int nparafile = 1");
        paraList.append("int numberOfGridProcessor = 0");
        paraList.append("int iovrlap = 0");
        paraList.append("int nsimutask = 1");
        paraList.append("string parafilename = \"./bin/grid_para.hypara\"");

        DataProperty::ParameterSelectable* ndim = getParameterSelectable(QStringLiteral("ndim"), d);
        QString ndimA[2] = { "3","2" };
        int paraIndex = ndim->getCurrentIndex();
        paraValue = ndimA[paraIndex];
        paraList.append("int " + QStringLiteral("ndim%1%2").arg(" = ").arg(paraValue));
    }
    else if (filename == (binPath + "grid_para.hypara"))
    {
        paraList.append("int gridtype = 0");
        paraList.append("int axisup = 1");
        paraList.append("int from_gtype = 5");
        paraList.append("int numberOfMultifile = 1");
        paraList.append("string from_gfile = \"./grid/mesh.msh\"");
        paraList.append("string out_gfile = \"./grid/mesh.fts\"");
    }
    else if (filename == (resultpath + "grid_para.hypara"))
    {
        //grid文件生成
        paraList.append("int gridtype = 0");
        paraList.append("int axisup = 1");
        paraList.append("int from_gtype = 5");
        paraList.append("int numberOfMultifile = 1");
        paraList.append("string from_gfile = \"./grid/mesh.msh\"");
        paraList.append("string out_gfile = \"./grid/mesh.fts\"");

    }
    else if (filename == (resultpath + "cfd_para_incompressible.hypara"))
    {
        paraList.append(splitLine);
        paraList.append("//                           Constants Parameters");
        paraList.append(splitLine);

        paraList.append("string gridfile = \"./grid/mesh.fts\";");
        paraList.append("int cellMethodOrNodeMethod = 0");
        paraList.append("int eqnSolverMethod = 0");
        paraList.append("int isAdaptiveSolver = 0");
        paraList.append("int nIsComputeWallDist = 1");
        paraList.append("double gridScaleFactor = 1.0");
        paraList.append("int intervalStepFlow  = 100");
        paraList.append("int intervalStepPlot  = 100");
        paraList.append("int intervalStepRes   = 10");
        paraList.append("int intervalStepForce = 10000;");
        paraList.append("string aircoeffile = \"incompForce\";");
        paraList.append("int compressible = 0");

        paraValue = getParameterGroupValue("maxSimuStep", "稳态设置", d);
        paraType = getParameterGroupType("maxSimuStep", "稳态设置", d);
        paraList.append(paraType + " " + "maxSimuStep" + " = " + paraValue);

        paraList.append(splitLine);
        paraList.append("//                           Initial Parameters");
        paraList.append(splitLine);

        paraValue = getParameterValue(QStringLiteral("initRho"), d);
        paraType = getParameterType(QStringLiteral("initRho"), d);
        paraList.append(paraType + QStringLiteral(" initRho%1%2").arg(" = ").arg(paraValue));

        paraValue = getParameterValue(QStringLiteral("initMu"), d);
        paraType = getParameterType(QStringLiteral("initMu"), d);
        paraList.append(paraType + QStringLiteral(" initMu%1%2").arg(" = ").arg(paraValue));

        paraValue = getParameterValue(QStringLiteral("initU"), d);
        paraType = getParameterType(QStringLiteral("initU"), d);
        paraList.append(paraType + QStringLiteral(" initU%1%2").arg(" = ").arg(paraValue));

        paraValue = getParameterValue(QStringLiteral("initV"), d);
        paraType = getParameterType(QStringLiteral("initV"), d);
        paraList.append(paraType + QStringLiteral(" initV%1%2").arg(" = ").arg(paraValue));

        paraValue = getParameterValue(QStringLiteral("initW"), d);
        paraType = getParameterType(QStringLiteral("initW"), d);
        paraList.append(paraType + QStringLiteral(" initW%1%2").arg(" = ").arg(paraValue));

        paraValue = getParameterValue(QStringLiteral("initP"), d);
        paraType = getParameterType(QStringLiteral("initP"), d);
        paraList.append(paraType + QStringLiteral(" initP%1%2").arg(" = ").arg(paraValue));

        paraList.append(splitLine);
        paraList.append("//                           Steady/Unsteady Parameters");
        paraList.append(splitLine);

        paraValue = getParameterGroupValue("iunsteady", "瞬态设置", d);
        if (paraValue == "true")
        {
            paraList.append("int iunsteady = 1");
        }
        else
        {
            paraList.append("int iunsteady = 0");
        }

        paraValue = getParameterGroupValue("startTime", "瞬态设置", d);
        paraType = getParameterGroupType("startTime", "瞬态设置", d);
        paraList.append(paraType + " " + "startTime" + " = " + paraValue);

        paraValue = getParameterGroupValue("endTime", "瞬态设置", d);
        paraType = getParameterGroupType("endTime", "瞬态设置", d);
        paraList.append(paraType + " " + "endTime" + " = " + paraValue);

        paraValue = getParameterGroupValue("dt", "瞬态设置", d);
        paraType = getParameterGroupType("dt", "瞬态设置", d);
        paraList.append(paraType + " " + "dt" + " = " + paraValue);

        paraValue = getParameterGroupValue("innerIter", "瞬态设置", d);
        paraType = getParameterGroupType("innerIter", "瞬态设置", d);
        paraList.append(paraType + " " + "innerIter" + " = " + paraValue);

        paraList.append("int OutputTimeStep = 1");

        paraList.append("int plotFieldType = 1");
        paraList.append("int momSolverMethod = 0");
        paraList.append("int pressureSolverMethod = 0");
        paraList.append("int scalarSolverMethod = 0");

        paraValue = getParameterGroupValue("SPECIES", "求解器", d);
        if (paraValue == "true")
        {
            paraList.append("int isSpecies = 1");
        }
        else
        {
            paraList.append("int isSpecies = 0");
        }

        QString solvers = " ";
        QString visualVariables = "22, 23, 24, 25";
        paraValue = getParameterGroupValue("FLOW", "求解器", d);
        if (paraValue == "true")
        {
            solvers = "FLOW";
            paraList.append("string FLOW_Variables[] = \"U V W P\"");
        }

        paraValue = getParameterGroupValue("ENERGY", "求解器", d);
        if (paraValue == "true")
        {
            solvers += ",ENERGY";
            visualVariables += ", 27, 70";
            nVisualVariables += 2;

            //Energy
            paraList.append(splitLine);
            paraList.append("//                           Energy Parameters");
            paraList.append(splitLine);
            paraList.append("string ENERGY_Variables[] = \"enthalpy\"");
            paraList.append("int energyType = 1");
            paraList.append("string ENERGY[] = [\"ENERGY\"]");
            paraList.append("string ENERGY_SCALAR_NAME[] = [\"enthalpy\"]");
            paraList.append("string energyPrintName[] = [\"H\"]");
            paraList.append("string precond_enthalpy = \"ILU\"");
            paraList.append("int maxSweep_enthalpy = 30");
            paraList.append("double iterSolvTol_enthalpy = 1e-12");
            paraList.append("int isBoussinesq = 1");
            paraList.append("double thermalExpansion = 3.44827e-3");

            paraValue = getParameterValue("res_enthalpy", d);
            paraList.append(QStringLiteral("double res_enthalpy = %1").arg(paraValue));

            paraValue = getParameterGroupValue("initT", "流场初始化", d);
            paraList.append(QStringLiteral("double initT = %1").arg(paraValue));

            paraValue = getParameterGroupValue("initK", "流场初始化", d);
            paraList.append(QStringLiteral("double initK = %1").arg(paraValue));

            paraValue = getParameterGroupValue("initCPg", "流场初始化", d);
            paraList.append(QStringLiteral("double initCPg = %1").arg(paraValue));

            paraValue = getParameterGroupValue("enthalpyInitValue", "流场初始化", d);
            paraList.append(QStringLiteral("double enthalpyInitValue = %1").arg(paraValue));

            paraValue = getParameterValue("urfT", d);
            paraList.append(QStringLiteral("double urfT = %1").arg(paraValue));

            paraValue = getParameterValue("urfH", d);
            paraList.append(QStringLiteral("double urfH = %1").arg(paraValue));

            DataProperty::ParameterSelectable* energyiterSolv = getParameterSelectable("energy_iterSolv", d);
            QString energyiterSolvA[3] = { "HYPRE_BiCGSTAB","UNAP_BiCGSTAB","BiCGSTAB" };
            int paraIndex = energyiterSolv->getCurrentIndex();
            paraValue = energyiterSolvA[paraIndex];
            paraList.append(QStringLiteral("string iterSolv_enthalpy = \"%1\"").arg(paraValue));

            DataProperty::ParameterSelectable* energyConv = getParameterSelectable("energy_Conv", d);
            QString energyConvA[4] = { "UPWIND","QUICK","CDS","SUDS" };
            paraIndex = energyConv->getCurrentIndex();
            paraValue = energyConvA[paraIndex];
            paraList.append(QStringLiteral("string energyConvCalc = \"%1\"").arg(paraValue));

            DataProperty::ParameterSelectable* energyDiff = getParameterSelectable("energy_Diff", d);
            QString energyDiffA[1] = { "NON_ORTHOGONAL" };
            paraIndex = energyDiff->getCurrentIndex();
            paraValue = energyDiffA[paraIndex];
            paraList.append(QStringLiteral("string energyDiffCalc = \"%1\"").arg(paraValue));

            DataProperty::ParameterSelectable* energyTran = getParameterSelectable("energy_Tran", d);
            QString energyTranA[3] = { "IMPLICIT_EULER","IMPLICIT_2ND_ORDER","CRANK_NICOLSON" };
            paraIndex = energyTran->getCurrentIndex();
            paraValue = energyTranA[paraIndex];
            paraList.append(QStringLiteral("string energyTranCalc = \"%1\"").arg(paraValue));

            paraList.append("string energySourceCalc[] = [\"EMPTY\"]");
            paraList.append("string energyGradCalc = \"GAUSS\"");
        }
        else
        {
            paraList.append("int energyType = 0");
        }

        paraValue = getParameterGroupValue("TURB_KEPSILON", "求解器", d);
        if (paraValue == "true")
        {
            solvers += ",TURB_KEPSILON";
            visualVariables += ", 29, 31, 32";
            nVisualVariables += 3;

            //Turbulence
            paraList.append(splitLine);
            paraList.append("//                           k-epsilon Parameters");
            paraList.append(splitLine);
            paraList.append("int viscousType = 13");
            paraList.append("string TURB_KEPSILON_Variables[] = \"epsilon,kinetic\"");
            paraList.append("string TURB_K_EPSILON[] = [\"TURB_K\",\"TURB_EPSILON\"]");
            paraList.append("string TURB_K_EPSILON_SCALAR_NAME[] = [\"kinetic\",\"epsilon\"]");
            paraList.append("string TURB_K[] = [\"TURB_K\"]");
            paraList.append("string TURB_K_SCALAR_NAME[] = [\"kinetic\"]");
            paraList.append("string TURB_EPSILON[] = [\"TURB_EPSILON\"]");
            paraList.append("string TURB_EPSILON_SCALAR_NAME[] = [\"epsilon\"]");
            paraList.append("int maxSweep_kinetic = 30");
            paraList.append("int maxSweep_epsilon = 30");
            paraList.append("double iterSolvTol_kinetic = 1e-12");
            paraList.append("double iterSolvTol_epsilon = 1e-12");
            paraList.append("string precond_kinetic=\"ILU\"");
            paraList.append("string precond_epsilon=\"ILU\"");

            paraValue = getParameterValue("urfMu", d);
            paraList.append(QStringLiteral("double urfMu = %1").arg(paraValue));

            paraValue = getParameterValue("ScalableWall", d);
            if (paraValue == "true")
            {
                paraList.append("int ScalableWall = 1");
            }
            else
            {
                paraList.append("int ScalableWall = 0");
            }

            DataProperty::ParameterSelectable* iterSolv_ke = getParameterSelectable("ke_iterSolv", d);
            QString iterSolv_keA[3] = { "HYPRE_BiCGSTAB","UNAP_BiCGSTAB","BiCGSTAB" };
            int paraIndex = iterSolv_ke->getCurrentIndex();
            paraValue = iterSolv_keA[paraIndex];
            paraList.append(QStringLiteral("string iterSolv_kinetic = \"%1\"").arg(paraValue));
            paraList.append(QStringLiteral("string iterSolv_epsilon = \"%1\"").arg(paraValue));

            DataProperty::ParameterSelectable* conv_ke = getParameterSelectable("ke_Conv", d);
            QString conv_keA[4] = { "UPWIND","QUICK","CDS","SUDS" };
            paraIndex = conv_ke->getCurrentIndex();
            paraValue = conv_keA[paraIndex];
            paraList.append(QStringLiteral("string kineticConvCalc = \"%1\"").arg(paraValue));
            paraList.append(QStringLiteral("string epsilonConvCalc = \"%1\"").arg(paraValue));

            DataProperty::ParameterSelectable* diff_ke = getParameterSelectable("ke_Diff", d);
            QString diff_keA[1] = { "NON_ORTHOGONAL" };
            paraIndex = diff_ke->getCurrentIndex();
            paraValue = diff_keA[paraIndex];
            paraList.append(QStringLiteral("string kineticDiffCalc = \"%1\"").arg(paraValue));
            paraList.append(QStringLiteral("string epsilonDiffCalc = \"%1\"").arg(paraValue));

            paraList.append(QStringLiteral("string kineticSourceCalc[] = \"TURB_K_DEFAULT\""));
            paraList.append(QStringLiteral("string epsilonSourceCalc[] = \"TURB_EPSILON_DEFAULT\""));

            //k parameter
            paraValue = getParameterGroupValue("kineticInitValue", "turbK", d);
            paraList.append(QStringLiteral("double kineticInitValue = %1").arg(paraValue));

            paraValue = getParameterGroupValue("kineticUrf", "turbK", d);
            paraList.append(QStringLiteral("double kineticUrf = %1").arg(paraValue));

            paraValue = getParameterGroupValue("kineticRes", "turbK", d);
            paraList.append(QStringLiteral("double kineticRes = %1").arg(paraValue));

            //epsilon parameter
            paraValue = getParameterGroupValue("epsilonInitValue", "turbE", d);
            paraList.append(QStringLiteral("double epsilonInitValue = %1").arg(paraValue));

            paraValue = getParameterGroupValue("epsilonUrf", "turbE", d);
            paraList.append(QStringLiteral("double epsilonUrf = %1").arg(paraValue));

            paraValue = getParameterGroupValue("epsilonRes", "turbE", d);
            paraList.append(QStringLiteral("double epsilonRes = %1").arg(paraValue));
        }

        paraValue = getParameterGroupValue("TURB_SA", "求解器", d);
        if (paraValue == "true")
        {
            solvers += ",TURB_SA";
        }

        paraList.append(splitLine);
        paraList.append("//                           Flow Settings");
        paraList.append(splitLine);

        paraList.append(QStringLiteral("string Solvers[] = \"%1\"").arg(solvers));
        paraList.append(QStringLiteral("int visualVariables[] = [%1]").arg(visualVariables));
        paraList.append("string FLOW[] = \"FLOW\"");

        paraList.append("int refPLocate = 0");
        paraList.append("double refArea= 1");
        paraList.append("double refVelocity = 1");
        paraList.append("double initRg = 287.0425");
        paraList.append("double refP = 101325");

        paraValue = getParameterGroupValue("urfU", "松弛因子", d);
        paraList.append(QStringLiteral("double urfU = %1").arg(paraValue));
        paraList.append(QStringLiteral("double urfV = %1").arg(paraValue));
        paraList.append(QStringLiteral("double urfW = %1").arg(paraValue));

        paraValue = getParameterGroupValue("urfP", "松弛因子", d);
        paraList.append(QStringLiteral("double urfP = %1").arg(paraValue));

        paraValue = getParameterGroupValue("urfFlux", "松弛因子", d);
        paraList.append(QStringLiteral("double urfFlux = %1").arg(paraValue));

        paraValue = getParameterGroupValue("resU", "残差设置", d);
        paraList.append(QStringLiteral("double resU = %1").arg(paraValue));

        paraValue = getParameterGroupValue("resV", "残差设置", d);
        paraList.append(QStringLiteral("double resV = %1").arg(paraValue));

        paraValue = getParameterGroupValue("resW", "残差设置", d);
        paraList.append(QStringLiteral("double resW = %1").arg(paraValue));

        paraValue = getParameterGroupValue("resP", "残差设置", d);
        paraList.append(QStringLiteral("double resP = %1").arg(paraValue));

        paraList.append("string initMatrixMethod = \"INITMATRIX_UNAP\"");
        paraList.append("string precond_U = \"ILU\"");
        paraList.append("string precond_V = \"ILU\"");
        paraList.append("string precond_W = \"ILU\"");
        paraList.append("string precond_P = \"ILU\"");

        DataProperty::ParameterSelectable* iterSolv_U = getParameterSelectable(QStringLiteral("iterSolv_U"), d);
        QString iterSolv_UA[3] = { "HYPRE_BiCGSTAB","UNAP_BiCGSTAB","BiCGSTAB" };
        int paraIndex = iterSolv_U->getCurrentIndex();
        paraValue = iterSolv_UA[paraIndex];
        paraList.append(QStringLiteral("string iterSolv_U = \"%1\"").arg(paraValue));
        paraList.append(QStringLiteral("string iterSolv_V = \"%1\"").arg(paraValue));
        paraList.append(QStringLiteral("string iterSolv_W = \"%1\"").arg(paraValue));

        DataProperty::ParameterSelectable* iterSolv_P = getParameterSelectable(QStringLiteral("iterSolv_P"), d);
        QString iterSolv_PA[3] = { "HYPRE_GMRES","UNAP_GMRES","AMG" };
        paraIndex = iterSolv_P->getCurrentIndex();
        paraValue = iterSolv_PA[paraIndex];
        paraList.append(QStringLiteral("string iterSolv_P = \"%1\"").arg(paraValue));

        paraList.append("int maxSweep_U = 30");
        paraList.append("int maxSweep_V = 30");
        paraList.append("int maxSweep_W = 30");
        paraList.append("int maxSweep_P = 30");

        paraValue = getParameterGroupValue("iterSolvTol_U", "残差设置", d);
        paraList.append(QStringLiteral("double iterSolvTol_U = %1").arg(paraValue));
        paraList.append(QStringLiteral("double iterSolvTol_V = %1").arg(paraValue));
        paraList.append(QStringLiteral("double iterSolvTol_W = %1").arg(paraValue));

        paraValue = getParameterGroupValue("iterSolvTol_P", "残差设置", d);
        paraList.append(QStringLiteral("double iterSolvTol_P = %1").arg(paraValue));

        paraList.append("string UGradCalc = \"GAUSS\"");
        paraList.append("string VGradCalc = \"GAUSS\"");
        paraList.append("string WGradCalc = \"GAUSS\"");
        paraList.append("string PGradCalc = \"GAUSS\"");

        DataProperty::ParameterSelectable* flowConvCalc = getParameterSelectable(QStringLiteral("对流项格式"), d);
        QString flowConvCalcA[4] = { "UPWIND","CDS","QUICK","SUDS" };
        paraIndex = flowConvCalc->getCurrentIndex();
        paraValue = flowConvCalcA[paraIndex];
        paraList.append(QStringLiteral("string flowConvCalc = \"%1\"").arg(paraValue));

        DataProperty::ParameterSelectable* flowDiffCalc = getParameterSelectable(QStringLiteral("扩散项格式"), d);
        QString flowDiffCalcA[1] = { "NON_ORTHOGONAL" };
        paraIndex = flowDiffCalc->getCurrentIndex();
        paraValue = flowDiffCalcA[paraIndex];
        paraList.append(QStringLiteral("string flowDiffCalc = \"%1\"").arg(paraValue));

        DataProperty::ParameterSelectable* flowTranCalc = getParameterSelectable(QStringLiteral("瞬态项格式"), d);
        QString flowTranCalcA[3] = { "IMPLICIT_EULER","IMPLICIT_2ND_ORDER","CRANK_NICOLSON" };
        paraIndex = flowTranCalc->getCurrentIndex();
        paraValue = flowTranCalcA[paraIndex];
        paraList.append(QStringLiteral("string flowTranCalc = \"%1\"").arg(paraValue));

        paraValue = getParameterGroupValue("gravity", "体积力", d);
        if (paraValue == "true")
        {
            paraList.append(QStringLiteral("string flowSourceCalc[] = \"%1\"").arg("FLOW_DEFAULT FLOW_GRAVITY"));
        }
        else
        {
            paraList.append(QStringLiteral("string flowSourceCalc[] = \"%1\"").arg("FLOW_DEFAULT"));
        }

        paraValue = getParameterGroupValue("bodyforce", "体积力", d);
        if (paraValue == "false")
        {
            paraList.append(QStringLiteral("int bodyForceFlag = 0"));
        }
        else
        {
            paraList.append(QStringLiteral("int bodyForceFlag = 1"));

            paraValue = getParameterGroupValue("x方向体积力", "体积力", d);
            paraList.append(QStringLiteral("double gravityX = %1").arg(paraValue));

            paraValue = getParameterGroupValue("y方向体积力", "体积力", d);
            paraList.append(QStringLiteral("double gravityY = %1").arg(paraValue));

            paraValue = getParameterGroupValue("z方向体积力", "体积力", d);
            paraList.append(QStringLiteral("double gravityZ = %1").arg(paraValue));
        }

        paraList.append(QStringLiteral("int nVisualVariables = %1").arg(nVisualVariables));

        //Material
        paraList.append(splitLine);
        paraList.append("//                           Material Parameters");
        paraList.append(splitLine);

        paraList.append("int iapplication = 0");
        paraList.append("int rhoType = 0");
        paraList.append("int muType = 0");
        paraList.append("int kType = 0");
        paraList.append("int cpType = 0");
        paraList.append("int massdiffType = 0");

        paraValue = getParameterGroupValue("numOfGas", "Material", d);
        paraList.append(QStringLiteral("int numOfGas = %1").arg(paraValue));

        paraValue = getParameterGroupValue("gasName", "Material", d);
        paraList.append(QStringLiteral("string gasName[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("gasMolarMass", "Material", d);
        paraList.append(QStringLiteral("double gasMolarMass[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("gasRho", "Material", d);
        paraList.append(QStringLiteral("double gasRho[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("gasMu", "Material", d);
        paraList.append(QStringLiteral("double gasMu[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("gasCp", "Material", d);
        paraList.append(QStringLiteral("double gasCp[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("gasK", "Material", d);
        paraList.append(QStringLiteral("double gasK[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("dilute", "Material", d);
        paraList.append(QStringLiteral("double dilute[] = [%1]").arg(paraValue));

        paraValue = getParameterGroupValue("refT", "Material", d);
        paraList.append(QStringLiteral("double refT = %1").arg(paraValue));

        //File in or out
        paraList.append(splitLine);
        paraList.append("//                           File In or Out");
        paraList.append(splitLine);

        paraList.append("int ifStartFromSteadyResults = 0");
        paraList.append("int isSubIterationDump = 1");
        paraList.append("string resSaveFile = \"results/res.dat\"");
        paraList.append("string restartFlowFile = \"results/pbFlow.dat\"");
        paraList.append("string restartEnergyFile = \"results/pbEnergy.dat\"");
        paraList.append("string restartSpecieFile = \"results/pbSpecie.dat\"");
        paraList.append("string restartTurbFile = \"results/turb.dat\"");
    }
    else if (filename == resultpath + "cfd_para.hypara")
    {

        paraList.append("            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\
//          PPPPP  H   H  EEEEE  N    N  GGGGG  L      EEEEE  III         +\n\
//          P   P  H   H  E      NN   N  G      L      E       I          +\n\
//          PPPPP  HHHHH  EEEEE  N N  N  G  GG  L      EEEEE   I          +\n\
//          P      H   H  E      N  N N  G   G  L      E       I          +\n\
//          P      H   H  EEEEE  N    N  GGGGG  LLLLL  EEEEE  III         +\n\
//------------------------------------------------------------------------+\n\
//          Platform for Hybrid Engineering Simulation of Flows           +\n\
//          China Aerodynamics Research and Development Center            +\n\
//                     (C) Copyright, Since 2010                          +\n\
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\
###########################################################################\n\
#                       Default parameters for Grid conversion            #\n\
###########################################################################\n\
// gridtype: Grid type for generation, conversion, reconstruction, merging.\n\
//           0 -- Unstructured grid.\n\
//           1 -- Structured grid.\n\
//           2 -- Hybrid grid, include both of unstructured and structured grid.\n\
// gridobj:  Task type of grid treatment.\n\
//           0 -- Grid generation of typical case, such as cylinder, flat plate, etc.\n\
//           1 -- Grid conversion, from other grid data to PHenglEI, such as Fluent, CGNS.\n\
//           2 -- Grid refinement.\n\
//           3 -- Grid merging, merge two blocks into one block.\n\
//           4 -- Grid deformation, achieve unstructured grid deformation.\n\
//           5 -- Grid repairing, repair the original grid in order to remove the negative volume cells.\n\
//           6 -- Grid mirroring, mirror a symmetry grid to whole grid.\n\
//			 7 -- Grid type change, convert structured grid to unstructured grid.\n\
// multiblock: Multi-block grid or not, only for structured grid conversion.\n\
//             0 -- Not.\n\
//             1 -- Yes.\n\
// iadapt: Adaptation number for unstructure grid.\n\
// SymmetryFaceVector: The vector of symmetry face.\n\
//             0 -- X axis.\n\
//             1 -- Y axis.\n\
//             2 -- Z axis.\n\
// gridReorder: Reorder cell and face of grid or not, only for 3D unstructured grid conversion,\n\
//              which is CGNS type.\n\
//             0 -- Not.\n\
//             1 -- Yes.\n\
// faceReorderMethod: the reorder method face of unstructured grid.\n\
//             0 -- BSFCELLFACEORG.\n\
//             1 -- BSFCELLFACELEFT. \n\
//             2 -- BSFCELLFACERIGHT.\n\
int gridtype            = 0;\n\
int gridobj             = 1;\n\
int multiblock          = 0;\n\
int iadapt              = 0;\n\
int SymmetryFaceVector  = 1;\n\
\n\
int gridReorder         = 0;\n\
int faceReorderMethod   = 0;\n\
\n\
// axisup: Type of Cartisien coordinates system, used in grid conversion.\n\
//         1 -- Y upward. (default)\n\
//         2 -- Z upward.\n\
int axisup = 1;\n\
\n\
// omit_no_bound_bc: What's boundary condition for the type of \"no_boundary_condition\".\n\
//                   0 -- Interface. (default)\n\
//                   1 -- Physical boundary condition, used in Hybrid solver.\n\
int omit_no_bound_bc = 0;\n\
\n\
            ");

        paraList.append("//-----------------------------------------------------------------------\n\
#                           Grid data type                              #\n\
//-----------------------------------------------------------------------\n\
// from_gtype/to_gtype: Type of grid data type in grid conversion process.\n\
//                     -1 -- MULTI_TYPE.\n\
//                      1 -- PHengLEI, *.fts.\n\
//                      2 -- CGNS, *.cgns.\n\
//                      3 -- Plot3D type of structured grid, *.dat/*.grd.\n\
//                      4 -- Fieldview type of unstructured grid, *.dat/*.inp.\n\
//                      5 -- Fluent, *.cas/*.msh.\n\
//                      6 -- Ustar, mgrid.in.\n\
//                      7 -- Hybrid, include both of unstructured and structured grid, *.fts.\n\
//                      8 -- GMSH, *.msh.\n\
//                      9 -- Gridgen type of structured grid, *.dat/*.grd.\n\
// dumpOldGrid: If dump out the old grid file.\n\
//              0 -- Not. (default)\n\
//              1 -- Yes.\n\
int from_gtype  = 2;\n\
int to_gtype    = 1;\n\
int dumpOldGrid = 0;\n\
\n\
//-----------------------------------------------------------------------\n\
#                           File path                                   #\n\
//-----------------------------------------------------------------------\n\
// from_gfile: path of original data file for unstructure grid convert from.\n\
// out_gfile:  path of target file for grid convert to, *.fts type of file usually.\n\
int numberOfGridFile = 1;\n\
string from_gfile = \"./grid/rae2822_hybrid2d.cas\";\n\
string from_gfile1= \"\";\n\
\n\
string out_gfile  = \"./grid/flat_laminr_133_85_2d.fts\";\n\
\n\
// ----------------- some advanced choices ------------------------------\n\
// iunsteady: The Grid is for unsteady simulation or not.\n\
int iunsteady = 0;\n\
\n\
// fileformat: Ustar Grid file format.\n\
//             0 -- BINARY.\n\
//             1 -- ASCII.\n\
int fileformat = 0;\n\
\n\
// Parameters for hybrid solver.\n\
// mixgrid_uns: path of unstructure grid file for hybrid solver, *.fts type.\n\
// mixgrid_str: path of structure grid file for hybrid solver, *.fts type.\n\
string mixgrid_uns    = \"./grid/rae2822_uns2d_4.fts\";\n\
string mixgrid_str    = \"./grid/flat_laminr_133_85_2d.fts\";\n\
\n\
// Some parameters for structured overlapping grid.\n\
int    codeOfDigHoles      = 1;\n\
string holeBasicFileName   = \"./oversetGridView/holeBasicFile.inp\";\n\
string holeFullFileName    = \"./oversetGridView/holeFullFile.dat\";\n\
string linkFileName        = \"./oversetGridView/topology.dat\";\n\
string zoneInverseFileName = \"./oversetGridView/zoneInverseMapping.inp\";\n\
\n\
// ----------------- Grid Refine Parameters -----------------------------\n\
// anisoRefine: If refine grid by anisoRefine type.\n\
//              0 -- Not. (default)\n\
//              1 -- Yes.\n\
// geometryUnit: Geometry unit.\n\
//               1 -- meter.\n\
//               2 -- millimeter.\n\
//               3 -- inch.\n\
// exclusiveCase: Parallel projection exclusive case.\n\
//                0 -- NON case.\n\
//                1 -- JSM-C2-NPOFF case.\n\
//                2 -- CHNT.\n\
// projectOrgPoint: If the original wall points need to be projected or not.\n\
int anisoRefine  = 0;\n\
int geometryUnit = 1;\n\
int isProject    = 0;\n\
int readDist     = 0;\n\
int isDeform     = 0;\n\
int exclusiveCase   = 0;\n\
int projectOrgPoint = 0;\n\
string geometryFileName = \"./grid/jsm.igs\";\n\
\n\
// ----------------- Grid Deform Parameters -----------------------------\n\
// deformationMethod: Grid Deform.\n\
//                1 -- SPRING.\n\
//                2 -- RBF.\n\
// stationalGridFile: Original grid file.\n\
// visualFileName   : The visualization file path of deform grid.\n\
// nDeformStep      : The max deform step.\n\
// flapAngle        :   The max flap angle.\n\
// rotatePostionZ   : Rotate postion.\n\
// rotatePostionY   : Rotate postion.\n\
// gridSlice        : If dump slice grid.\n\
// sliceAxis        : Grid slice axis.\n\
// slicePosition    : Grid slice position.\n\
int    nDeformStep    = 40;\n\
double flapAngle      = 10.0;\n\
double rotatePostionZ = 4.00003;\n\
double rotatePostionY = 3.05;\n\
\n\
int    deformationMethod = 2;\n\
string stationalGridFile = \"./grid/Segment2Brid.fts\";\n\
string visualFileName    = \"./results/deformedGrid.dat\"\n\
\n\
int    gridSlice     = 1;\n\
int    sliceAxis     = 1;\n\
double slicePosition = 13;\n\
\n\
// ----------------- RBF Parameters -------------------------------------\n\
// numberOfReferenceCP : Number of reference Control Points.\n\
// influencePara       : The RBF influence radius parameter.\n\
int numberOfReferenceCP = 40;\n\
double influencePara = 25.0;\n\
\n\
// ----------------- Periodic Parameters --------------------------------\n\
// Notice: Rotational periodicity only support rotation along the X axis!\n\
// periodicType: Which periodic boundary is used.\n\
//               0 -- without Periodic Boundary.\n\
//               1 -- Translational periodicity.\n\
//               2 -- Rotational periodicity.\n\
// translationLength[]: The relative distance between two periodic face\n\
                        which only support one direction.\n\
// rotationAngle: The relative angle between two periodic face.\n\
                  which is recorded in degrees.  \n\
\n\
int periodicType = 0; \n\
double translationLength[] = [0.0,0.0,0.0];\n\
double rotationAngle = 0.0;\n\
\n\
#########################################################################\n\
#                       Default parameters for Partition                #\n\
#########################################################################\n\
// pgridtype: The grid type.\n\
//            0 -- unstruct grid.\n\
//            1 -- struct grid.\n\
//            2 -- refine structured grid.\n\
// maxproc: The number of partition zones that want to be divided into.\n\
// numberOfMultifile: The number of partition grid files that want to be dumped out.\n\
\n\
int pgridtype = 0;\n\
int maxproc   = 4;\n\
int numberOfMultifile = 1;\n\
\n\
// traceMark: Trace mark or not, only for structured grid partition.\n\
//            0 -- Not.\n\
//            1 -- Yes.\n\
// blockIndexOfMark: the block index of mark, only for structured grid partition.\n\
// cellIndexOfMark: the cell index of mark, only for structured grid partition.\n\
int traceMark        = 0;\n\
int blockIndexOfMark = 0;\n\
int cellIndexOfMark[] = [185,30,1];\n\
\n\
// parallel Strategy:\n\
//! -# 0 : each zone is assigned to the one that defined in grid partition procedure.\n\
//! -# 1 : random assigned for each zone or by some else ways.\n\
int parallelStrategy = 1;  \n\
\n\
            ");

       paraList.append("//-----------------------------------------------------------------------\n\
#                           File path                                   #\n\
//-----------------------------------------------------------------------\n\
// original_grid_file: Original grid file that want to be divided(PHengLEI type, *.fts).\n\
// partition_grid_file: Target partition grid file(PHengLEI type, *.fts).\n\
string original_grid_file  = \"./grid/sphere_mixed.fts\";\n\
string partition_grid_file = \"./grid/sphere_mixed__4.fts\";\n\
\n\
// ------------------ Sompe advanced parameters -------------------------\n\
// omit_no_bound_bc: What's boundary condition for the type of \"no_boundary_condition\".\n\
//                   0 -- Interface. (default)\n\
//                   1 -- Physical boundary condition, used in Hybrid solver.\n\
// npartmethod: Method of interface reconstruction, default is 1.\n\
// parallelPartitionMethod: Method of parallel partition, this is set only when execute parallel partition. It would be skipped when serial partition.\n\
//                   1 -- Using ParMetis for homogeneous MPI.\n\
//                   2 -- Using Metis for homogeneous MPI.\n\
//                   3 -- using METIS partition for homogeneous OpenMP.\n\
// parmetisBalance: Used to specify the imbalance tolerance.\n\
//                   1 -- perfect balance.\n\
//             maxproc -- perfect imbalance.\n\
//                1.05 -- recommended.\n\
\n\
int omit_no_bound_bc        = 0;\n\
int npartmethod             = 1;\n\
int parallelPartitionMethod = 2;\n\
double parmetisBalance = 1.05;\n\
\n\
// numberOfMultigrid: Number of multi-grid levels, ONLY used for structured grid.\n\
//                    1 -- single level.\n\
//                    2 -- 2 level.\n\
//                    N -- N level, ..., et al.\n\
int numberOfMultigrid = 1;\n\
\n\
#########################################################################\n\
#                     Default parameters for CFD simulation             #\n\
#########################################################################\n\
// maxSimuStep: The max simulation step, don't care simulation is restart or not.\n\
// intervalStepFlow: The step intervals for flow variables file 'flow.dat' saved.\n\
// intervalStepPlot: The step intervals for tecplot visual file 'tecflow.dat' saved.\n\
// intervalStepSample: The step intervals for monitored probes variables file 'sample.dat' saved.\n\
// intervalStepForce: The step intervals for aerodynamics coefficients file 'aircoef.dat' saved.\n\
// intervalStepRes: The step intervals for residual file 'res.dat' saved.\n\
// ifLowSpeedPrecon: Precondition process to accelerate convergence for low speed flow.\n\
//                   0 -- no precondition process. (default, mach > 0.3)\n\
//                   1 -- carry out precondition process. (mach number <= 0.3)\n\
\n\
int maxSimuStep       = 20000;\n\
\n\
int intervalStepFlow  = 1000;\n\
int intervalStepPlot  = 1000;\n\
int intervalStepSample = 1000;\n\
int intervalStepForce = 100;\n\
int intervalStepRes   = 10;\n\
int ifLowSpeedPrecon  = 0;\n\
\n\
// compressible:\n\
//               0 -- incompressible flow.\n\
//               1 -- compressible flow. (default)\n\
int compressible = 1;\n\
\n\
//-----------------------------------------------------------------------\n\
#                           CFD Control Parameter                       #\n\
//-----------------------------------------------------------------------\n\
// refMachNumber: Mach number.\n\
// attackd: Angle of attack.\n\
// angleSlide: Angle of sideslip.\n\
// inflowParaType: The type of inflow parameters.\n\
//                 0 -- the nondimensional conditions.\n\
//                 1 -- the flight conditions.\n\
//                 2 -- the experiment conditions.\n\
//                 3 -- the subsonic boundary conditions.\n\
//                 4 -- the condition that the velocity, temperature and density are given.\n\
//                 5 -- the condition that the velocity, temperature and pressure are given.\n\
// refReNumber: Reynolds number, which is based unit length, unit of 1/m.\n\
// refDimensionalTemperature: Dimensional reference temperature, or the total temperature only for the experiment condition.\n\
// freestream_vibration_temperature: Dimensional freestream vibration temperature.\n\
// refDimensionalPressure: Dimensional reference pressure, or the total pressure only for the experiment condition.\n\
// height: Fly height, unit of km.\n\
// wallTemperature: Temprature of the solid wall, minus value is for adiabatic boundary condition.\n\
// gridScaleFactor: The customizable unit of the grid, default value is 1.0 for meter.Common dimensions like:\n\
//                    1 dm = 0.1  m.\n\
//                    1 cm = 0.01 m.\n\
//                    1 mm = 0.001m.\n\
//                    1 inch             = 0.0254m.\n\
//                    1 foot = 12 inches = 0.3048m.\n\
//                    1 yard = 3  feet   = 0.9144m.\n\
// forceReferenceLength, forceReferenceLengthSpanWise, forceReferenceArea: Reference length, SpanWise length and area, independent of grid unit.\n\
// TorqueRefX, TorqueRefY, TorqueRefZ: Reference point, independent of grid unit.\n\
// radiationCoef: The radiation coefficient on wall, it is used to compute the radiation heat flux on wall when the boundary\n\
//                condition is radiation equilibrium temperature, and 0.8 is the default value.\n\
// refMolecularWeight : the reference molecular weight of gas used for perfect gas. The unit is g/mol.\n\
// Generally, the gas is air. Sometimes, it is experiment gas, such as Nitrogen, Argon, and so on.\n\
\n\
int directionMethod = 0;\n\
double refMachNumber = 0.73;\n\
double attackd       = 2.79;\n\
double angleSlide    = 0.00;\n\
\n\
int inflowParaType = 0;\n\
double refReNumber = 6.5e6;\n\
double refDimensionalTemperature = 288.15;\n\
double freestream_vibration_temperature = 300.00;\n\
\n\
//int inflowParaType = 1;\n\
//double height = 0.001;\n\
\n\
//int inflowParaType = 2;\n\
//double refDimensionalTemperature = 6051.024;    // The total temperature, T*(1+(refGama-1)*M*M/2).\n\
//double refDimensionalPressure = 4.299696E09;    // The total pressure, p*(T0/T)^(refGama/(refGama-1)).\n\
\n\
//int inflowParaType = 3;\n\
//int nsubsonicInlet  = 1;\n\
//int nsubsonicOutlet = 1;\n\
//string inLetFileName  = \"./bin/subsonicInlet.hypara\";\n\
//string outLetFileName = \"./bin/subsonicOutlet.hypara\";\n\
//double refDimensionalTemperature = 288.144;\n\
//double refDimensionalPressure = 1.01313E05;\n\
\n\
//The velocity, temperature and density are fixed.\n\
//int inflowParaType = 4;\n\
//double refDimensionalVelocity = 1000.0;\n\
//double refDimensionalDensity = 1.0e3;\n\
\n\
//The velocity, temperature and pressure are fixed.\n\
//int inflowParaType = 5;\n\
//double refDimensionalVelocity = 1000.0;\n\
//double refDimensionalPressure = 1.0e5;\n\
\n\
//The MachNumber, temperature and pressure are fixed.\n\
//int inflowParaType = 6;\n\
//double refDimensionalTemperature = 293;\n\
//double refDimensionalPressure = 8886.06;\n\
\n\
double wallTemperature = -1.0;\n\
\n\
double radiationCoef = 0.8;\n\
double gridScaleFactor = 1.0;\n\
double gridTranslationVector[] = [0.0, 0.0, 0.0];\n\
\n\
int numberOfAerodynamicForceComponents = 1;\n\
double forceReferenceLengthSpanWise = 1.0;    // unit of meter.\n\
double forceReferenceLength = 1.0;            // unit of meter.\n\
double forceReferenceArea = 1.0;              // unit of meter^2.\n\
double TorqueRefX = 0.0;                      // unit of meter. \n\
double TorqueRefY = 0.0;                      // unit of meter.\n\
double TorqueRefZ = 0.0;                      // unit of meter.\n\
double refMolecularWeight = 28.9644;          // unit of g/mol.\n\
\n\
//-----------------------------------------------------------------------\n\
#                           Spatial Discretisation                      #\n\
//-----------------------------------------------------------------------\n\
#\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
*#                         Struct Solver                            \n\
*#\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
*// inviscidSchemeName: Spatial discretisation scheme of struct grid.\n\
//                     Using this when solve structered grid or hybrid.\n\
//                     -- \"vanleer\", \"steger\", \"hlle\", \"lax_f\".\n\
//                     -- \"roe\", \"modified_roe\".\n\
//                     -- \"ausm+\", \"ausm+w\", \"ausm+up\", \"ausmdv\", \"ausmpw\", \"ausmpw+\".\n\
// isWennScheme: If using WENN Scheme of struct grid.\n\
//               0 -- NO. (default)\n\
//               1 -- Yes.\n\
// str_limiter_name: Limiter of struct grid.\n\
//                     -- \"vanalbada\", \"vanleer\", \"minmod\", \"smooth\", \"minvan\", \"3rdsmooth\", \"3rd_minmod_smooth\".\n\
//                     -- \"nolim\", no limiter.\n\
//                     -- \"vanalbada_clz\", clz supersonic version.\n\
//                     -- \"weno3_js\", \"wenn3_prm211\", \"wenn3_zm\", \"wenn3_zes2\", \"wenn3_zes3\"\n\
\n\
string inviscidSchemeName = \"roe\";\n\
int isWennScheme = 0;\n\
string str_limiter_name   = \"vanalbada\";\n\
\n\
#\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
*#                         UnStruct Solver or Common                \n\
*#\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
*// viscousType: Viscous model.\n\
//           0 -- Euler.\n\
//           1 -- Lamilar.\n\
//           2 -- Algebraic.\n\
//           3 -- 1eq turbulent.\n\
//           4 -- 2eq turbulent.\n\
// viscousName: Laminar or tubulent model.\n\
//              -- \"0eq-bl\".\n\
//              -- \"1eq-sa\".\n\
//              -- \"2eq-kw-menter-sst\".\n\
//              -- \"2eq-kw-menter-bsl\".\n\
//              -- \"2eq-kw-wilcox-1988\".\n\
//              -- \"2eq-kw-wilcox-1998\".\n\
//              -- \"2eq-kw-kok-tnt\".\n\
//              -- \"2eq-kw-wilcox-2006\".\n\
//              -- \"easm-kw-2003\".\n\
//              -- \"easm-kw-2005\".\n\
// DESType: Type of DES.\n\
//          0 -- RANS. (default)\n\
//          1 -- DES.\n\
//          2 -- DDES.\n\
//          3 -- IDDES.\n\
// uns_scheme_name: Spatial discretisation scheme of Unstruct grid.\n\
//                  Using this when solve Unstructered grid or hybrid.\n\
//                  -- \"vanleer\", \"roe\", \"steger\", \"kfvs\", \"lax_f\", \"hlle\".\n\
//                  -- \"ausm+\", \"ausmdv\", \"ausm+w\", \"ausmpw\", \"ausmpw+\".\n\
// uns_limiter_name: Limiter of Unstruct grid.\n\
//                   -- \"barth\", \"vencat\", \"vanleer\", \"minmod\".\n\
//                   -- \"vanalbada\", \"smooth\", \"nnd\", \"lpz\", \"1st\".\n\
//                   -- \"nolim\", no limiter.\n\
// uns_vis_name: Discretisation method of viscous term.\n\
//               -- \"std\", \"test\", \"aver\", \"new1\", \"new2\".\n\
// gradientName: Gradient reconstruction method.\n\
//                 -- \"default\", \"ggcell\", \"ggnode\", \"lsq\".\n\
// ivencat: Variation of vencat limiter.\n\
//          0 -- org method, it is independent of grid scale.\n\
//          1 -- new method, it is dependent of grid scale.\n\
//          4 -- Ustar limiter model, without grid size unitary.\n\
//          7 -- default used.\n\
// venkatCoeff: Cofficient of vencat, when using vencat limter.\n\
// limitVariables: Limit model (It is useful only if limitVector is 0).\n\
//                 0 -- limit only for pressure and denstiny, then get the min value.\n\
//                 1 -- limit for every variables, then get the min value.\n\
// limitVector:\n\
//              0 -- Each variable use the same limiter coefficient.\n\
//              1 -- Each variable use the respective limiter coefficients.\n\
// reconmeth:\n\
//              0 -- When reconstruct face value, Q+, Q- use respective limiter coefficients.\n\
//              1 -- Q+, Q- use the min limiter coefficients of left and right cell.\n\
// skewnessAngle: The skewness angle of grid cells.\n\
// roeEntropyFixMethod: Entropy fix (correction) method.\n\
//              1 -- direct fix, which limits the minimum eigenvalue directly.\n\
//              2 -- multi-dimensional fix, which is derived from structured solver and now is only valid for struct solver.\n\
//              3 -- Harten type, which is default used.\n\
// roeEntropyScale: Entropy fix (correction) coefficient scale, default is 1.0.\n\
//                  It is used to scale the default Roe entropy fix coefficients.\n\
// AusmpwPlusLimiter: A Limiter to make \"function w\" not change acutely in AusmpwPlus scheme, default is 1.0\n\
\n\
//int    viscousType    = 0;\n\
//string viscousName = \"Euler\";\n\
\n\
//int    viscousType    = 1;\n\
//string viscousName = \"laminar\";\n\
\n\
int    viscousType    = 3;\n\
string viscousName = \"1eq-sa\";\n\
\n\
//int    viscousType    = 4;\n\
//string viscousName = \"2eq-kw-menter-sst\";\n\
\n\
int DESType = 0;\n\
\n\
string uns_scheme_name  = \"roe\";\n\
string uns_limiter_name = \"vencat\";\n\
string uns_vis_name     = \"test\";\n\
string gradientName     = \"ggnode\";\n\
\n\
int    ivencat     = 7;\n\
double venkatCoeff = 5.0;\n\
int reconmeth      = 1;\n\
int limitVariables = 0;\n\
int limitVector    = 0;\n\
double skewnessAngle = 60.0;\n\
\n\
int roeEntropyFixMethod = 3;\n\
double roeEntropyScale  = 1.0;\n\
\n\
double AusmpwPlusLimiter = 1.0;\n\
\n\
           ");
    paraList.append("//-----------------------------------------------------------------------\n\
#                       Temporal Discretisation                         #\n\
//-----------------------------------------------------------------------\n\
// iunsteady: Steady or unsteady.\n\
//            0 -- steady.\n\
//            1 -- unsteay.\n\
// physicalTimeStep: The nondimensional physical time step.\n\
// ifStartFromSteadyResults: The unsteady simulation is start from steady flowfield or not, 0 is for no and else is for yes.\n\
// ifStaticsFlowField: Statistical variables for unsteady simulation.\n\
// ifStaticsReynoldsStress: Statistical Reynolds stress for unsteady simulation.\n\
// startStatisticStep: Outer step when start statistics.\n\
//                     when the value is larger than \"maxSimuStep\", it is useless.\n\
// statisticalTimePeriod: Used as time period of statistic analysis.\n\
//                        when the value is negative, time period is treated as infinite.\n\
// statisticMethod: Statistic reynolds stress method.\n\
//               0 -- tau = <q^2> - <q>^2\n\
//               1 -- tau = <u'u'>\n\
// min_sub_iter: The min sub iteration of unsteady simulation.\n\
// max_sub_iter: The max sub iteration of unsteady simulation.\n\
// tol_sub_iter: The tolerance of sub iteration of unsteady simulation.\n\
// tscheme: Temporal Discretisation method.\n\
//               1 -- Runge-Kutta Multi-State.\n\
//               2 -- Point implicit.\n\
//               3 -- Full implicit.\n\
//               4 -- LU-SGS.\n\
//               5 -- Block LU-SGS.\n\
//               6 -- Jacobian iteration.\n\
//               7 -- Line LU-SGS.\n\
//               8 -- Matrix LU-SGS.\n\
// iSimplifyViscousTerm: Simplify the computation of viscous term in the Block LU-SGS method. The default value assigns 1 that could speed up the computation.\n\
//                       Otherwise, the viscous Jacobian matrix Mv should be computed that will increase the memory and time in iteration of the BLUSGS method.\n\
// CFLStart: Started cfl number.\n\
// CFLEnd: End cfl number.\n\
// CFLVaryStep: The number of step when cfl increase from CFLStart to CFLEnd.\n\
// ktmax: Dtratio. dt[i] = MIN(dt[i], ktmax * dtmin / vol[i])\n\
// swapDq: Communication dq between forward/backward sweep of LUSGS or not, default is 0.\n\
// nLUSGSSweeps: Sub iteration of LU-SGS or Block LU-SGS.\n\
// LUSGSTolerance: Sub iter tolerance of LU-SGS or Block LU-SGS.\n\
// ifLocalTimeStep: Time step method.\n\
//               0 --Local.\n\
//               1 --Global.\n\
// isUseLocalCFL: use variable number of CFL or not.\n\
//               0 -- global unified CFL number.\n\
//               1 -- local CFL number.\n\
// isUsePreTwall: use the previous temperatures on wall. 1 indicates yes, and 0 indicates no.\n\
// visl_min: Minimum value of laminar viscosity coefficient.\n\
// turbCFLScale: Turbulence model cfl number factor.\n\
// codeOfAleModel: Arbitrary Lagrangian-Eulerian method.\n\
//               0 -- no ALE method.\n\
//               1 -- ALE method for non-moving grids.\n\
//               2 -- ALE method for moving grids.\n\
//               3 -- ALE method for deforming grids.\n\
// wallFunctionType: The type of wall function to implement.\n\
//               0 -- no wall function. (default)\n\
//               1 -- standard wall function.\n\
//               2 -- Pab3D wall function.\n\
// RKStage: The number of Runge-Kutta step.\n\
// lamda: Cofficient of Runge-Kutta step.\n\
\n\
int    iunsteady        = 0;\n\
double physicalTimeStep = 0.01;\n\
double physicalTimeStepDimensional = -0.001;\n\
int    ifStartFromSteadyResults = 0;\n\
int    ifStaticsFlowField = 0;\n\
int    ifStaticsReynoldsStress = 0;\n\
int    startStatisticStep = 800000;\n\
double statisticalTimePeriod = -1.0;\n\
int    statisticMethod = 0;\n\
int    linearTwoStepMethods = 1;    // 1--BDF1; 2--C-N; 3--BDF2;\n\
\n\
int    methodOfDualTime = 3;\n\
int    min_sub_iter = 50;\n\
int    max_sub_iter = 50;\n\
double tol_sub_iter = 0.01;\n\
\n\
int    tscheme      = 4;\n\
int    iSimplifyViscousTerm = 1;\n\
int    ifLocalTimeStep = 0;\n\
int    isUseLocalCFL = 0;\n\
int    isUsePreTwall = 0;\n\
double CFLStart     = 0.01;\n\
double CFLEnd       = 10.0;\n\
int    CFLVaryStep  = 500;\n\
\n\
double pMaxForCFL = 0.2;\n\
double pMinForCFL = 0.1;\n\
double deltaMaxForCFL = 0.2;\n\
double magnifyFactorForCFL = 1.1;\n\
double reduceFactorForCFL = 0.5;\n\
\n\
double ktmax        = 1.0e10;\n\
\n\
int    swapDq       = 1;\n\
\n\
int    nLUSGSSweeps = 1;\n\
double LUSGSTolerance = 0.01;\n\
int    order        = 2;\n\
\n\
double visl_min = 0.01;\n\
double turbCFLScale = 1.0;\n\
double csrv     = 2.0;\n\
double timemax  = 1.0e10;\n\
double dtsave   = -1.0;\n\
int    maxale   = 10;\n\
double dtau     = 0.001;\n\
\n\
int wallFunctionType = 0;\n\
\n\
int RKStage    = 2;\n\
double lamda[] = [0.5, 1.0];\n\
\n\
//int RKStage    = 1;\n\
//double lamda[] = 1.0;\n\
\n\
//int RKStage    = 4;\n\
//double lamda[] = [0.25, 0.33333333333, 0.5, 1.0];\n\
\n\
        ");
        paraList.append("//-----------------------------------------------------------------------\n\
#                           File In or Out                              #\n\
//-----------------------------------------------------------------------\n\
// numberOfGridGroups: The number of grid groups.\n\
// gridfile: The partitioned Grid file path, using relative path,\n\
//           which is relative to the working directory.\n\
// IMPORTANT WARNING: The file index should be ignored,\n\
//                    e.g. if the partitioned grid is rae2822_hybrid2d__4_0.fts,\n\
//                    please use 'rae2822_hybrid2d__4.fts' here!\n\
// plotFieldType: If dump out the field results to visulization.\n\
// walldistMethod: The method to compute wall distance.\n\
//                 0 -- accurate but not fast enough.\n\
//                 1 -- fast but not accurate enough.\n\
//                 2 -- super fast but more non-accurate!\n\
// resSaveFile: The file path to save the residual convergence process, write data for every default (intervalStepRes) steps.\n\
// turbresfile: The file path to save the residual convergence process of turbulence, write data for every default (intervalStepRes) steps.\n\
// aircoeffile: The file path to save the aerodynamic force coefficients convergence process, write data for every default (intervalStepForce) steps.\n\
// restartNSFile: The file path to write restart flowfield variables, write data for every default (intervalStepFlow) steps.\n\
// turbfile: The file path to write restart flowfield variables of turbulence , write data for every default(intervalStepFlow) steps.\n\
// visualfile: The visualization file path of flowfield , write data for every default (intervalStepPlot) steps.\n\
// wall_aircoefile: The file path to save flowfield variables of wall, write data for every default steps.\n\
// nDumpSurfaceInfo = 0 the \"wall_varfile\" write the informations including heat flux.\n\
// nDumpSurfaceInfo = 1 the \"wall_varfile\" write the informations without heat flux.\n\
// nIsComputeWallDist: Whether to compute the wall distance.  \n\
//                     0 -- Compute wall distance.\n\
//                     1 -- Not compute.\n\
// \n\
// protectionFile0 and protectionFile1 : Two continuation file  of the data protection mechanism.\n\
// wall_heatfluxfile : The file to output the MaxHeatFlux of wall.\n\
\n\
int    numberOfGridGroups = 1;\n\
string gridfile           = \"./grid/rae2822_hybrid2d__4.fts\";\n\
string wallTemperaturefile= \"\";\n\
\n\
int    nIsComputeWallDist = 0;\n\
int    walldistMethod     = 1;\n\
int    cellMethodOrNodeMethod = 0;\n\
\n\
string resSaveFile        = \"results/res.dat\";\n\
string turbresfile        = \"results/turbres.dat\";\n\
string aircoeffile        = \"results/aircoef.dat\";\n\
\n\
string restartNSFile      = \"results/flow.dat\";\n\
string turbfile           = \"results/turb.dat\";\n\
\n\
string visualfile         = \"results/tecflow.plt\";\n\
string wall_aircoefile    = \"results/wall_aircoef.dat\";\n\
string samplefile         = \"results/sample.dat\";\n\
\n\
string protectionFile0    = \"results/flow0.dat\";\n\
string protectionFile1    = \"results/flow1.dat\";\n\
string wall_heatfluxfile  = \"results/wall_heatflux.dat\";\n\
\n\
int nDumpSurfaceInfo      = 0;\n\
string wall_varfile       = \"\";\n\
\n\
string jetDefineFile      = \"bin/jet.hypara\";\n\
\n\
string sixDofFileName     = \"results/sixDofInfo.dat\";\n\
string derivativeFileName = \"results/identify.dat\";\n\
string hysteresisFileName = \"results/force_beta.plt\";\n\
\n\
int plotFieldType = 0;\n\
\n\
// visualfileType: The file type of visualfile.\n\
//                 0 -- Tecplot binary.\n\
//                 1 -- Tecplot ASCII.\n\
\n\
int visualfileType = 1;\n\
\n\
// samplefileMode: The dump mode of sample file.\n\
//                 0 -- dump out every probe/line/surface data for all step intervals.\n\
//                 1 -- dump out all probe/line/surface data for every step intervals.\n\
int samplefileMode = 0;\n\
\n\
// visualSlice: The slice of tecflow.\n\
//              0 -- Do not save slice data.\n\
//              1 -- comput and save it to sliceFile.\n\
// sliceAxis: Normal vector of slice.\n\
//            1 -- X_DIR.\n\
//            2 -- Y_DIR.\n\
//            3 -- Z_DIR.\n\
// slicePostion: Coordinate of slice.\n\
\n\
int    visualSlice  = 0;\n\
int    sliceAxis    = 1;\n\
double slicePostion = -0.5;\n\
string sliceFile    = \"results/Slice.plt\";\n\
int    dumpWallFaceCenter = 0;\n\
\n\
// min-max box of the visual block.\n\
double lowerPlotFieldBox[] = [0.0 0.0 0.0];\n\
double upperPlotFieldBox[] = [1.0 1.0 1.0];\n\
\n\
//-----------the optional parameters list for the flow field output----------------\n\
// nVisualVariables: Number of variables want to be dumped for tecplot visualization.\n\
// visualVariables : Variable types dumped, listed as following:\n\
//                   -- density(0), u(1), v(2), w(3), pressure(4), temperature(5), mach(6),\n\
//                   -- viscosityLaminar(7), viscosityTurbulent(8), \n\
//                   -- vorticity_x(9), vorticity_y(10), vorticity_z(11), vorticityMagnitude(12),\n\
//                   -- strain_rate(13), Q_criteria(14), Cp(15), timeStep(16), volume(17),\n\
//                   -- modeledTKE(18), modeleddissipationrate(19), SSTF1(20), SSTF2(21), \n\
//                   -- vibration temperature(Tv, 33), electron temperature(Te, 34), vibrational energy(Ev, 35), electric energy(Ee, 36),\n\
//                   -- number density of electron(Ne, 37), dimensioanl density(rho, 38), dimensioanl pressure(p, 39), dimensioanl temperature(T, 40),\n\
//                   -- gradientUx(41), gradientUy(42), gradientVx(43), gradientVy(44), streamline_u(45), streamline_v(46), streamline_w(47),\n\
//                   -- transition intermittency(intermittency, 51), -transition momentum thickness reynolds(MomentumThicknessReynolds, 52),\n\
//                   -- overlap iblank(iblank, 81)\n\
\n\
//                   -- specific heat ratio(gama, 56)\n\
// Important Warning: Array size of visualVariables MUST be equal to nVisualVariables!!!\n\
// Variables order must from small to big.\n\
//-----------the optional parameters list for the wall boundary condition----------------\n\
// nVisualWallVariables: The number of visual variables on wall.\n\
// visualWallVariables : dumped variable types, listed as following:\n\
// -coefficient of pressure(cp, 0), -coefficient of friction(cf, 1), yplus(2), -non-dimensional heat flux(Q_NonDim, 3), -dimensional heat flux(Q_Dim, 4),\n\
// -pressure on wall(pw, 5), -temperature on wall(Tw, 6), -density on wall(rhow, 7), -heat flux of translational-rotational temperature term(Qtr, 8),\n\
// -heat flux of species diffusion term(Qs, 9), -heat flux of vibrational temperature term(Qv, 10), -heat flux of electron temperature term(Qe, 11),\n\
// -species mass fractions(Ns, 12), -x component of wall velocity(Vx, 13), -y component of wall velocity(Vy, 14), -z component of wall velocity(Vz, 15)\n\
// -slip translational-rotational temperature(Tts, 16), -slip vibrational temperature(Tvs, 17), -slip electron temperature(Tes, 18), -absolute wall velocity(Vs, 19)\n\
// -Stanton number(St, 20), -coefficient of heat rate(Ch, 21), -temperature jump(deltaT, 22), -Grid Reynolds number on wall(Re_w, 23)\n\
int nVisualVariables = 8;\n\
int visualVariables[] = [0, 1, 2, 3, 4, 5, 6, 15];\n\
\n\
int nVisualWallVariables = 9;\n\
int visualWallVariables[] = [0, 1, 2, 3, 4, 5, 9, 10, 11];\n\
\n\
// dumpStandardModel: Dump many standard model data.\n\
//                    1 -- Turbulent flat plate.\n\
int dumpStandardModel = 0;\n\
\n\
// ifSetDataMonitor: Whether to set the data monitor.\n\
//                   0 -- No.\n\
//                   1 -- Yes.\n\
// dataMonitorType: The type of data Monitor.\n\
//                  0 -- Probes data monitor.\n\
//                  1 -- Lines data monitor.\n\
//                  2 -- Surfaces data monitor.\n\
// probesDefineFile: Probes location information file.\n\
// nLines: The number of lines need to be monitored.\n\
// linesDefineFile: Lines location information file.\n\
// nSurfaces: The number of surfaces need to be monitored.\n\
// surfacesDefineFile: Surfaces location information file.\n\
// searchCellsMethod: method to search the cell of each probe.\n\
//                    0 -- Nearest cell to the probe.\n\
//                    1 -- Real cell where the probe is located.\n\
// nProbeVariables: Number of variables want to be dumped for probes monitered.\n\
// probeVariables : Variable types dumped, listed as following:\n\
//                  -- density(0), u(1), v(2), w(3), pressure(4), temperature(5), mach(6).\n\
// Important Warning: Array size of probeVariables MUST be equal to nProbeVariables!!!\n\
// probeVariables order must from small to big.\n\
// probeVariablesInterpolationMethod: Interpolation method used to compute the probe variables.\n\
//                 0 -- Take the value of probe's cell as probe real value.\n\
//                 1 -- Interpolation from probe's and neighbouring cell to probe.\n\
//                 2 -- Interpolation from probe's cell nodes to probe.\n\
int ifSetDataMonitor = 0;\n\
\n\
int    dataMonitorType = 0;\n\
string probesDefineFile = \"bin/probes_XYZ.dat\";\n\
\n\
//int    dataMonitorType = 1;\n\
//int    nLines = 1;\n\
//string linesDefineFile = \"bin/lines_XYZ.dat\";\n\
\n\
//int    dataMonitorType = 2;\n\
//int    nSurfaces = 4;\n\
//string surfacesDefineFile = \"bin/surfaces_XYZ.dat\";\n\
\n\
int searchCellsMethod = 0;\n\
\n\
int nProbeVariables  = 7;\n\
int probeVariables[] = [0, 1, 2, 3, 4, 5, 6];\n\
int probeVariablesInterpolationMethod  = 0;\n\
            ");
            paraList.append("//-----------------------------------------------------------------------\n\
#                           Turbulence Parameter                        #\n\
//-----------------------------------------------------------------------\n\
// turbInterval: Iteration number of turbulence.\n\
// kindOfTurbSource: Kinds of turbulent source.\n\
//                   0 -- Original.\n\
// mod_turb_res: If modify the residuals for the cells next to the wall or not, default is 0.\n\
// transitionType:  transition model type\n\
//                   0 -- none.\n\
//                   2 -- gama-re-theta.\n\
// turbIntensity:  (valid while greater than 0.0 ) turbulent intensity of free stream(*100) in transition\n\
// freeturbIntensitySRModify: to use SR modify in free stream turbulent intensity decay or not\n\
\n\
\n\
int turbInterval     = 1;\n\
int turbOrderStruct  = 2;\n\
int kindOfTurbSource = 0;\n\
int mod_turb_res     = 0;\n\
double turb_relax    = 1.0;\n\
double freeStreamViscosity = 1.0e-3;\n\
double muoo          = 3.0;\n\
double kwoo          = 5.0;\n\
int transitionType   = 0;\n\
double turbIntensity = -1.0;\n\
int freeturbIntensitySRModify = 0;\n\
double freeDecayXLocation = 0.0;\n\
int compressibleCorrection  = 0;\n\
int prandtlNumberCorrection = 0;\n\
int transitionMaFix = 1;\n\
\n\
# maximum eddy viscosity (myt/my) max.\n\
double eddyViscosityLimit = 1.0e10;\n\
int monitor_vistmax = 0;\n\
\n\
//-----------------------------------------------------------------------\n\
#                           LES Parameter                               #\n\
//-----------------------------------------------------------------------\n\
// iLES: Create LESSolver or not.\n\
//       =  1 - Create LESSolver;\n\
//      !=  1 - not.\n\
// amplitudeofDisturb: Amplitude of adding disturb.\n\
// disturbstep: Unsteady time step or steady iteration of adding random disturb.\n\
// iterdisturb: Add random disturb in every sub-iter or only first sub-iter.\n\
//              = 0 - in only first sub-iter;\n\
//             != 0 - in every sub-iter.\n\
// ipraddisturb: Add density and pressure disturb or not.\n\
// ibodyforce: Add body force in source flux of NS equations or not.\n\
//             = 0 - not;\n\
//            != 0 - Add body force.\n\
// bodyforce: Body force in source flux of NS equations or not.\n\
// utau: friction velocity, using in DNSDisturb.\n\
// sgsmodel: subgrid scale model.\n\
//           = \"smagorinsky\";\n\
//           = \"dsmCom\";\n\
//           = \"wale\";\n\
//           = \"sigma\".\n\
// deltaFunctionType: = 1 - MAX(deltai, deltaj, deltak);\n\
//                    = 2 - pow(deltai * deltaj *deltak, 1/3);\n\
//                    = 3 - Devloped by Scotti.\n\
// wallDampingFunctionType: = 0 - no wall function;\n\
//                          = 1 - van Driest;\n\
//                          = 2 - developed by Dr. Deng Xiaobing;\n\
//                          = 3 - developed by Piomelli.\n\
// turbViscousCutType: turbulent viscosity cut type.\n\
//                     = 0 - mu_total = mut           + mul;\n\
//                     = 1 - mu_total = max(mut-mul,0)+ mul;\n\
//                     = 2 - mu_total = max(mut    ,0)+ mul.\n\
// smagConstant: constant of smagorinsky model.\n\
// waleConstant: constant of wale model.\n\
// filterDirection[3]: filter variables in i, j, k direction or not.\n\
// averageDirection[3]: average variables in i, j, k direction or not.\n\
// isotropicConstant: constant of isotropic part of SGS stress.\n\
\n\
int    iLES               = 0;\n\
string sgsmodel           = \"smagorinsky\";\n\
int    deltaFunctionType  = 2;\n\
int    wallDampingFunctionType = 1;\n\
int    turbViscousCutType = 2;\n\
double smagConstant       = 0.1;\n\
double isotropicConstant  = 0.0;\n\
double waleConstant       = 0.6;\n\
double sigmaConstant      = 1.35;\n\
int    filterDirection[]  = [1, 1, 0];\n\
int    averageDirection[] = [0, 0, 0];\n\
double testFilterScale    = 2.0;\n\
int    averageWidth       = 1;\n\
int    monitorNegativeConstant = 0;\n\
\n\
                ");

            paraList.append("\n\
int dg_high_order = 0;\n\
int iapplication  = 0;\n\
int isAdaptiveSolver = 0;\n\
int nm            = 5;\n\
int nEquilibriumGas = 0;\n\
int nPCWCycleStep = 3;\n\
int nRETCycleStep = 3;\n\
int nSLIPCycleStep= 3;\n\
int nIterFirstStep = 1000;\n\
int nIterSecondStep= 2000;\n\
int nIterThirdStep = 2000;\n\
int nEnergyAssembly = 0;\n\
int nControlVariable = 1;\n\
double firstStepError  = 0.01;\n\
double secondStepError = 0.001;\n\
double thirdStepError  = 0.001;\n\
double predictCFLError = 0.1;\n\
\n\
double refGama    = 1.4;\n\
double prl        = 0.72;\n\
double prt        = 0.90;\n\
double sc_l       = 0.5;\n\
double sc_t       = 0.5;\n\
\n\
int    nGasModel  = 0;\n\
int    nchem      = 0;\n\
int    nchemsrc   = 1;\n\
int    nchemrad   = 1;\n\
int    ntmodel    = 1;\n\
\n\
int nIdealState = 0;\n\
int nEnergyRecycle = 1;\n\
int nSlipBCModel   = 0;\n\
int nDensityModify = 1;\n\
int nTEnergyModel  = 0;\n\
int nMeanFreePathType = 0;\n\
int nIsChemicalFreeze = 0;\n\
int nIsSuperCatalytic = 1;\n\
int nTemperatureJump  = 0;\n\
int nSurfGradMethod = 0;\n\
int nRapidFlowfield = 0;\n\
int nSurfHeatMonitor = 0;\n\
int nInitPressureStep = 100;\n\
int nDumpCFLNumber = 0;\n\
\n\
double parkVDPower   = 0.6;\n\
double catalyticCoef = 0.0;\n\
double sigmaVelocity = 1.0;\n\
double sigmaTemperature = 1.0;\n\
double sigmaMassFraction = 1.0;\n\
double velocitySlipCorrectConstant = 1.0;\n\
\n\
double chemicalRelaxCorf        = 1.0;\n\
double chemicalSpectrumRadiusCoef = 1.0;\n\
double viscousSpectrumRadiusCoef  = 1.5;\n\
double inviscidSpectrumRadiusCoef = 1.5;\n\
double spectrumRadiusCoef 	= 0.5;\n\
double staticPressureRelaxCorf  = 0.2;\n\
\n\
double maxViscous = 10000.0;\n\
double trTemperatureMin = 10.0;\n\
double veTemperatureMin = 30.0;\n\
double maxTemperature = 50000.0;\n\
double densityMin = 1.0e-8;\n\
double densityMinFactor = 0.1;\n\
double tAdjustmentFactor = 10.0;\n\
double iniSpeedCoef = 1.0;\n\
\n\
int    nDebug = 0;\n\
int    nSpeciesLimit = 1;\n\
int    nTurblenceForChemical = 0;\n\
int    nViscosityFluxSublevelModified = 1;\n\
int    nViscosityPeModified = 0;\n\
int    nChemcalSourceModified = 2;\n\
int    nChemcalSourceEsMethod = 1;\n\
int    nMaxStepTemperature  = 5;\n\
int    veTemperatureMinModified = 1;\n\
int    nDiagonalModified = 0;\n\
int    nGradPrimtiveMethod = 1;\n\
int    nInviscidFluxModify = 1;\n\
int    nQlLimitMethod = 2;\n\
int    nSpeciesForWallMethod = 1;\n\
int    nDensityForWallMethod = 0;\n\
\n\
int    nProtectData = 0;\n\
int    useHyflowSetting = 0;\n\
int    nAblation   = 0;\n\
int    isInjection = 0;\n\
int    nViscosityModel = 0;\n\
int    nMarsModel = 0;\n\
string gasfile    = \"DK5\";\n\
//string gasfile    = \"./chemical/Dunn-Kang_air5s11r.dat\";\n\
string speciesName = \"O, O2, NO, N, N2\";\n\
string initMassFraction = \"0.0, 0.233, 0.0, 0.0, 0.767\";\n\
\n\
//string speciesName = \"O, O2, NO, N, NO+, N2, e-\";\n\
//string initMassFraction = \"0.0, 0.233, 0.0, 0.0, 0.0, 0.767, 0.0\";\n\
\n\
//string speciesName = \"O, O2, NO, N, O+, O2+, NO+, N+, N2+, N2, e-\";\n\
//string initMassFraction = \"0.0, 0.233, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.767, 0.0\";\n\
\n\
//string gasfile = \"Mars-Pa8\";\n\
//string speciesName = \"O, O2, NO, N, N2, C, CO, CO2\";\n\
//string initMassFraction = \"0.0015, 0.0429, 0.0, 0.0, 0.0, 0.0, 0.0777, 0.8779\";\n\
\n\
//string gasfile    = \"Pa\";\n\
//string speciesName = \"O, O2, NO, N, NO+, C, C2, CO, CO2, CN, N2, e-\";\n\
//string initMassFraction = \"0.0, 0.233, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.767, 0.0\";\n\
\n\
//string gasfile    = \"Combustion-12\";\n\
//string speciesName = \"O, O2, NO, N, C, CO, CO2, H, H2, OH, H2O, N2\";\n\
//string initMassFraction = \"0.0, 0.233, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.767\";\n\
 \n\
//string gasfile = \"Gas-Mixture\";\n\
//string speciesName =\"SpeciesA, SpeciesB\";\n\
//string initMassFraction = \"1.0, 0.0\";\n\
int    nSutherland  = 0;\n\
double gamaSpeciesA = 1.4;\n\
double gamaSpeciesB = 1.3;\n\
double molecularWeightSpeciesA = 29.0;\n\
double molecularWeightSpeciesB = 30.0;\n\
\n\
//string gasfile = \"Gas-Mixture\";\n\
//string speciesName = \"O2, N2\";\n\
//string initMassFraction = \"1.0, 0.0\";\n\
\n\
int nContinueModel = 0;\n\
int nChemicalFlowStep = 0;\n\
int ifStartFromPerfectGasResults = 0;\n\
\n\
               ");
               paraList.append("int nMGLevel = 1;\n\
int MGCoarsestIteration = 1;\n\
int MGPreIteration = 1;\n\
int MGFasType = 1;\n\
int n_post = 0;\n\
int flowInitStep = 100;\n\
int mprol = 2;\n\
double mgCFLScale = 1.0;\n\
double mgCorrectionLimit = 0.01;\n\
\n\
//--------------- Some parameter for turbulent model --------------------\n\
// neasm: The variation of kw turbulent model.\n\
// ismooth_turb: Residual smooth for turb or not.\n\
// SSTProductType: The type of product term based on vorticity for SST.\n\
// SAProductType: The type of product term based on vorticity for SA.\n\
int neasm = -3;\n\
int SSTProductType = 0;\n\
int ismooth_turb = 0;\n\
int SAProductType = 2;\n\
\n\
// ----------------- Overset Grid parameter -----------------------------\n\
int    codeOfDigHoles       = 1;\n\
int    codeOfTurbulentModel = 0;\n\
string masterFileName       = \"./grid/searchFile.inp\";\n\
string holeBasicFileName    = \"./grid/holeBasicFile.inp\";\n\
string holeFullFileName     = \"./grid/holeFullFile.dat\";\n\
string linkFileName         = \"./grid/topology.dat\";\n\
string zoneInverseFileName  = \"./grid/zoneInverseMapping.inp\";\n\
\n\
#########################################################################\n\
#                       High Order Struct Solver                        #\n\
#########################################################################\n\
// isFVMOrFDM:\n\
//        0 -- NSSolverStruct using Finite Volume Method.\n\
//        1 -- NSSolverStruct using Finite Differ Method.\n\
// SolverStructOrder: Spatial discretisation order of NS equations with struct grid.\n\
//                    <= 2 -- finite volume method.\n\
//                    >= 3 -- finite difference order. (to be completed)\n\
//                       0 -- default.\n\
// str_highorder_interpolation_epsilon: Epsilon in weighted interpolation, bigger epsilon, better convergence,\n\
//                                      smaller epsilon, robuster for shock-detecting.\n\
// str_highorder_interpolation_type:\n\
//                    -- \"classical\", \"test\".\n\
// str_highorder_flux_name:\n\
//                    -- \"roe\", \"steger\".\n\
// structhighordergradient:\n\
//                    -- \"conservation\", \"chain_rule\".\n\
int    isFVMOrFDM                          = 0;\n\
string str_highorder_solver                = \"WCNS\";\n\
int    SolverStructOrder                   = 0;\n\
double str_highorder_interpolation_epsilon = 1.0e-6;\n\
string str_highorder_interpolation_type    = \"test\";\n\
string str_highorder_flux_name             = \"steger\";\n\
string structhighordergradient             = \"conservation\";\n\
double coefofstrflux        = 0.5;\n\
double limitcoefofinterface = 0.0;\n\
\n\
// ----------------- Advanced choices -----------------------------------\n\
// outtimesc: Time stepping scheme for the outer loop.\n\
// MUSCLCoefXk: The parameter of MUSCL interpolations, belongs to [-1, 1].\n\
//             -1 -- seconde-order fully-upwind differencing.\n\
//              0 -- seconde-order upwind-biased differencing.\n\
//       0.333333 -- third-order upwind-biased differencing.\n\
//              1 -- seconde-order central differencing.\n\
// MUSCLCoefXb: The limiter parameter.\n\
//              0 -- the effect of the limiter is cancelled, means the first-order interpolations.\n\
// allReduceStep: Iteration intervals for MPI AllReduce operation, default is 1.\n\
string outtimesc   = \"impbd2\";\n\
double MUSCLCoefXk = -1;\n\
double MUSCLCoefXb = 1.0;\n\
int  allReduceStep = 1;\n\
\n\
// ----------------- overlap configuration ------------------------------\n\
// codeOfOversetGrid: Overlapping(overset) grid or not.\n\
//             0 -- NON-overlapping grid.\n\
//             1 -- Overlapping grid.\n\
// oversetInterpolationMethod: the method of overset interpolation while field simulation\n\
//             0 -- set the acceptor cell value by donor cell value.\n\
//             1 -- set the acceptor cell value by distance weight of donor cell value.\n\
\n\
int    codeOfOversetGrid           = 0;\n\
int    oversetInterpolationMethod  = 0;\n\
int    readOversetFileOrNot        = 0;\n\
int    symetryOrNot                = 0;\n\
int    readInAuxiliaryInnerGrid    = 0;\n\
int    readInAuxiliaryOuterGrid    = 0;\n\
int    readInSklFileOrNot          = 0;\n\
string auxiliaryInnerGrid0         = \"./grid/aux-upper.fts\";\n\
string auxiliaryInnerGrid1         = \"./grid/aux-lower.fts\";\n\
string auxiliaryInnerGrid2         = \"\";\n\
string oversetGridFileName         = \"./grid/iblank.ovs\";\n\
double walldistMainZone            = 1.0\n\
double toleranceForOversetSearch   = 1.0e-3;\n\
double toleranceForOversetBox      = 1.0e-3;\n\
int    twoOrderInterpolationOrNot  = 0;\n\
int    keyEnlargeOfActiveNodes     = 0;\n\
int    outTecplotOverset           = 0;\n\
int    outPutOversetVisualization  = 0;\n\
\n\
int     numberOfMovingBodies       = 2;\n\
\n\
// ----------------- ALE configuration ------------------------------\n\
int codeOfAleModel                = 0;\n\
int aleStartStrategy              = -1;\n\
\n\
double referenceLength            = 1.0;\n\
double referenceVelocity          = 1.0;\n\
double referenceDensity           = 1.0;\n\
\n\
int strategyForFaceNormalVelocity = 0; //0-By Sweeping volume; 1-By face center 1st; 2-By face center 2nd; \n\
int strategyForGCLSource          = 0; //0-present; 1-Ahn;\n\
\n\
//0:1st-Admas-Bashforth; 1:2nd-Admas-Bashforth; 2:1st-Implicit-Euler; 3:2nd-Implicit Euler; 4:2nd-Adams-Moulton; 5:3rd-Adams-Moulton\n\
int    methodForKineticEquation   = 0;\n\
double relaxParameterOfKinetic    = 1.0;\n\
\n\
                   ");

                   paraList.append("int    numberOfMovingBodies = 1;\n\
\n\
##############################    body0    ##############################\n\
//mass of parts\n\
double mass_0                  = 1.0;\n\
//mass matrix of parts               Ixx       Iyy       Izz       Ixy       Ixz       Iyz\n\
double massMatrix_0[]          = 1e-7,     1e-6,     1e-6,     0.0,      0.0,      0.0;\n\
//initial six DOF position information of parts.    xc        yc        zc\n\
double massCenter_0[]          = 0.0 ,    0.0,      0.0;\n\
//initial six DOF position information of parts.    angleX    angleY    angleZ\n\
double attitudeAngle_0[]       = 0.0 ,     0.0,      0.0;\n\
//initial six DOF move information of parts.    vc        vy        vz\n\
double massCenterVelocity_0[]  = 0.0,      0.0,      0.0;\n\
//initial six DOF move information of parts.    omigX     omigY     omigZ\n\
double angularVelocity_0[]     = 0.0,      0.0,      0.0;\n\
//the object that the parts belong to.\n\
int    fartherIndex_0          = -1;\n\
//the assembly position of the parts.                xc        yc        zc        angleX    angleY    angleZ\n\
double configPamameter_0[]     = 0.0      ,0.0      ,0.0      ,0.0      ,0.0      ,0.0;\n\
//the move pattern of the parts.\n\
// -1  given motion partten.\n\
//  0  still.\n\
//  1  six DOF motion.\n\
//  2  three DOF motion.\n\
// 11  X-axis forced motion.\n\
// 12  Y-axis forced motion.\n\
// 13  Z-axis forced motion.\n\
// 14  forced pitch motion.\n\
// 15  forced yaw motion.\n\
// 16  forced roll motion.\n\
int  RBDMethod_0                = 0;\n\
double amplitude_0              = 0.0;\n\
double reduceFrequency_0        = 0.0;\n\
//direction of rotation\n\
//         1 -- clockwise from the point of view along the positive x axis.\n\
//        -1 -- anticlockwise from the point of view along the positive x axis.\n\
int direction_0                 = -1;\n\
double rotateFrequency_0        = 0.0;\n\
//string uDFSixDofFileName_0    = \"./Bin/UDFSixDof.Parameter\";\n\
//additional force  (system axis)             fX        fY        fZ        \n\
double addedForce_0[]           = 0.0      ,0.0      ,0.0       ;\n\
//additional moment of Force  (system axis)             mX        mY        mZ        \n\
double addedMoment_0[]          = 0.0      ,0.0      ,0.0       ;\n\
//the deformation method of the parts.\n\
int    morphing_0               = 0;\n\
\n\
// post indentify\n\
int    integralOrder            = 4;\n\
\n\
\n\
// ---------------- ATP read --------------------------------------------\n\
//@int    inflowParaType            = 0;\n\
//@double refReNumber = 6.5e6;\n\
//@double refDimensionalTemperature = 288.15;\n\
//@double freestream_vibration_temperature = 300.00;\n\
//@double refDimensionalPressure    = 0;\n\
//@double height                    = 0;\n\
//@int nsubsonicInlet               = 0;\n\
//@int nsubsonicOutlet              = 0;\n\
//@string inLetFileName             = \"./bin/subsonicInlet.hypara\";\n\
//@string outLetFileName            = \"./bin/subsonicOutlet.hypara\";\n\
//@double refDimensionalVelocity = 0;\n\
//@double refDimensionalDensity = 0;\n\
\n\
#########################################################################\n\
#                             Old Parameter                             #\n\
#########################################################################\n\
int isPlotVolumeField = 0;\n\
\n\
\n\
#########################################################################\n\
#                         Incompressible Parameter                      #\n\
#########################################################################\n\
\n\
int isSolveEnergyEquation = 0;\n\
int isSolveTurbEquation = 0;\n\
int isSolveSpeciesEquation = 0;\n\
\n\
                       ");
    }

    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))return false;
    QTextStream stream(&file);
    for (int i = 0; i < paraList.count(); ++i)
    {
        stream << paraList.at(i)+";" << endl;
    }

    return true;
}

bool PHENGLEIPLUGINAPI writeMeshText(QString filename, ModelData::ModelDataBase* d)
{
    QString paraValue;
    QStringList paraList;
    return true;
}

QString getParameterValue(QString paraname, ModelData::ModelDataBase*d)
{
    QString t;
    DataProperty::ParameterBase* p = d->getParameterByName(paraname);
    if (p != nullptr)
    {
        if (p->getParaType() == DataProperty::Para_String)
        {
            t = p->valueToString();
        }
        else if (p->getParaType() == DataProperty::Para_Int)
        {
            DataProperty::ParameterInt* pInt = (DataProperty::ParameterInt*)(p);
            t = QString("%1").arg(pInt->getValue());
        }
        else if (p->getParaType() == DataProperty::Para_Double)
        {
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            t = QString("%1").arg(pDouble->getValue());
        }
        else if (p->getParaType() == DataProperty::Para_Bool) {
            DataProperty::ParameterBool* pBool = (DataProperty::ParameterBool*)(p);
            return pBool->valueToString();
            if (pBool->getValue())
            {
                t = QString("%1").arg("true");
            }
            else
            {
                t = QString("%1").arg("false");
            }
        }
        else if (p->getParaType() == DataProperty::Para_Path)
        {
            DataProperty::ParameterPath* path = (DataProperty::ParameterPath*)(p);
            t = path->getFile();
        }
        return t;
    }
    else
    {
        return "0.0000";
    }
}

QString getParameterType(QString paraname, ModelData::ModelDataBase* d)
{
    QString t;
    DataProperty::ParameterBase* p = d->getParameterByName(paraname);

    if (p != nullptr)
    {
        DataProperty::ParaType paraType = p->getParaType();
        if (paraType == DataProperty::Para_Int)
        {
            t = "int";
        }
        else if (paraType == DataProperty::Para_Double)
        {
            t = "double";
        }
        else if (paraType == DataProperty::Para_Bool)
        {
            t = "bool";
        }
        return t;
    }
    else
    {
        return "unknown type";
    }
}

DataProperty::ParameterTable* getParameterTable(QString paraname, ModelData::ModelDataBase*d)
{
    DataProperty::ParameterTable* result = nullptr;
    DataProperty::ParameterBase* p = d->getParameterByName(paraname);
    if (p != nullptr)
    {
        if (p->getParaType() == DataProperty::Para_Table)
        {
            result = (DataProperty::ParameterTable*)(p);
        }
    }
    return result;
}

DataProperty::ParameterSelectable* getParameterSelectable(QString paraname, ModelData::ModelDataBase* d)
{
    DataProperty::ParameterSelectable* result = nullptr;
    DataProperty::ParameterBase* p = d->getParameterByName(paraname);
    if (p != nullptr)
    {
        if (p->getParaType() == DataProperty::Para_Selectable)
        {
            result = (DataProperty::ParameterSelectable*)(p);
        }
    }
    return result;
}

QString getParameterGroupValue(QString paraname, QString rootname, ModelData::ModelDataBase* d)
{
    QString t;
    DataProperty::ParameterGroup* paraGroup = d->getParameterGroupByName(rootname);
    if (paraGroup != nullptr)
    {
        auto* p = paraGroup->getParameterByName(paraname);
        if (p != nullptr)
        {
            if (p->getParaType() == DataProperty::Para_String)
            {
                t = p->valueToString();
            }
            else if (p->getParaType() == DataProperty::Para_Int)
            {
                DataProperty::ParameterInt* pInt = (DataProperty::ParameterInt*)(p);
                t = QString("%1").arg(pInt->getValue());
            }
            else if (p->getParaType() == DataProperty::Para_Double)
            {
                DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
                t = QString("%1").arg(pDouble->getValue());
            }
            else if (p->getParaType() == DataProperty::Para_Bool) {
                DataProperty::ParameterBool* pBool = (DataProperty::ParameterBool*)(p);
                return pBool->valueToString();
                if (pBool->getValue())
                {
                    t = QString("%1").arg("true");
                }
                else
                {
                    t = QString("%1").arg("false");
                }
            }
            return t;
        }
        else
        {
            return "0.0000";
        }
    }
    else
    {
        return "0.0000";
    }
    
}

QString getParameterGroupType(QString paraname, QString rootname, ModelData::ModelDataBase* d)
{
    QString t;
    DataProperty::ParameterGroup* paraGroup = d->getParameterGroupByName(rootname);
    if (paraGroup != nullptr)
    {
        auto* p = paraGroup->getParameterByName(paraname);
        if (p != nullptr)
        {
            DataProperty::ParaType paraType = p->getParaType();
            if (paraType == DataProperty::Para_Int)
            {
                t = "int";
            }
            else if (paraType == DataProperty::Para_Double)
            {
                t = "double";
            }
            else if (paraType == DataProperty::Para_Bool)
            {
                t = "bool";
            }
            return t;
        }
        else
        {
            return "unknown type";
        }
    }
    else
    {
        return "null";
    }
}

void showmsg(QString inputtext)
{
	QMessageBox msgBox;
	msgBox.setText(inputtext);
	msgBox.exec();
}

bool PHENGLEIPLUGINAPI transfileToDest(const QString &fromDir, const QString &toDir, int type)
{
    return true;
}

bool PHENGLEIPLUGINAPI writeScriptFile(QString filename, ModelData::ModelDataBase* d)
{
    return true;
}

bool BCOperation(ModelData::ModelDataBase* d, QString& boundaryFilePath)
{
    int nBC = d->getBCCount();
    if (nBC == 0) { return true; }
    for (int iBC = 0; iBC < nBC; ++iBC)
    {
        BCBase::BCBase* pBC = d->getBCAt(iBC);
        BCBase::BCType bcType = pBC->getBCType();
        QString ComponentName = pBC->getComponentName();
        QString bcTypename = BCTypeToString(bcType);
        qDebug() << bcTypename;
        if (bcTypename == "PressureOutlet") // 对应风雷中的Pressure Outlet
        {
            DataProperty::ParameterBase* p = pBC->getParameterByName("PressureOutlet");
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            double paraValue = pDouble->getValue();
            if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowP", paraValue, d))
            {
                return false;
            }
        }
        else if (bcTypename == "VelocityInlet") // 对应风雷中的Velocity Inlet
        {
            DataProperty::ParameterBase* p = pBC->getParameterByName("InletX");
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            double paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowU", paraValue, d))
                {
                    return false;
                }
            }
            p = pBC->getParameterByName("InletY");
            pDouble = (DataProperty::ParameterDouble*)(p);
            paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowV", paraValue, d))
                {
                    return false;
                }
            }
            p = pBC->getParameterByName("InletZ");
            pDouble = (DataProperty::ParameterDouble*)(p);
            paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowW", paraValue, d))
                {
                    return false;
                }
            }
        }
        else if (bcTypename == "Wall") // 对应风雷中的Wall
        {
            if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "wall", 0, d))
            {
                return false;
            }
        }
        else if (bcTypename == "MovingWall")
        {
            DataProperty::ParameterBase* p = pBC->getParameterByName("MovingX");
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            double paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowU", paraValue, d))
                {
                    return false;
                }
            }
            p = pBC->getParameterByName("MovingY");
            pDouble = (DataProperty::ParameterDouble*)(p);
            paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowV", paraValue, d))
                {
                    return false;
                }
            }
            p = pBC->getParameterByName("MovingZ");
            pDouble = (DataProperty::ParameterDouble*)(p);
            paraValue = pDouble->getValue();
            if (!(paraValue == 0))
            {
                if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "flowW", paraValue, d))
                {
                    return false;
                }
            }
        }
        else if (bcTypename == "FixTWall")
        {
            DataProperty::ParameterBase* p = pBC->getParameterByName("Fix T");
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            double paraValue = pDouble->getValue();
            if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "T", paraValue, d))
            {
                return false;
            }
        }
        else if (bcTypename == "FixHeatFluxWall")
        {
            DataProperty::ParameterBase* p = pBC->getParameterByName("Fix Heat Flux");
            DataProperty::ParameterDouble* pDouble = (DataProperty::ParameterDouble*)(p);
            double paraValue = pDouble->getValue();
            if (!insertBCInfo(boundaryFilePath, ComponentName, bcTypename, "wallq", paraValue, d))
            {
                return false;
            }
            
        }

    }


    return true;
}

bool insertBCInfo(QString& boundaryFilePath, QString bcName, QString bcType, QString bcCondition, double bcValue, ModelData::ModelDataBase* d)
{
    // 1. 读入路径boundary文件
    QString boundaryData;
    QStringList boundaryDataR;
    QFile boundaryFile(boundaryFilePath);
    if (boundaryFile.open(QFile::ReadWrite | QFile::Text))
    {
        while (!boundaryFile.atEnd())
        {
            boundaryData += boundaryFile.readLine();
        }
        boundaryDataR = boundaryData.split("\n");
        // 2. 通过bcName定位要修改的边界组件 string bcName = "wall";

        QString bcFullName = "string bcName = \"" + bcName + "\";";
        int index = boundaryDataR.indexOf(bcFullName, Qt::CaseSensitive);
        if (-1 == index)
        {
            qDebug() << "can not find correspond boundary component";
            return false;
        }

        // 3. 将原有该bcName下参数删除
        int finiLine = index + 3;
        for (int i = index; i < boundaryDataR.size(); i++)
        {
            if (boundaryDataR[i] == "}")
            {
                finiLine = i;
                break;
            }
        }
        int lineNeedToDelete = finiLine - index - 2;
        for (int j = 1;  j <= lineNeedToDelete; j++)
        {
            boundaryDataR.removeAt(index + 2);
        }


        // 4. 写入对应的边界条件
        QString isKE = getParameterGroupValue("TURB_KEPSILON", "求解器", d);
        QString isEnergy = getParameterGroupValue("ENERGY", "求解器", d);
        QString paraValue;

        if (bcType == "Wall")
        {
            //Turb_ke
            if (isKE == "true")
            {
                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_WALL\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_WALL\";");
            }

            //Energy
            if (isEnergy == "true")
            {
                boundaryDataR.insert(index + 2, "string energyBoundaryType = \"ENERGY_WALL\";");
            }

            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_SOLID_SURFACE\";");
            boundaryDataR.insert(index + 2, "int bcType = 2;");
        }
        else if (bcType == "MovingWall")
        {
            //Energy
            if (isEnergy == "true")
            {
                boundaryDataR.insert(index + 2, "string energyBoundaryType = \"ENERGY_WALL\";");
            }
            
            //Turb_ke
            if (isKE == "true")
            {
                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_WALL\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_WALL\";");
            }
            
            QString t = QString("double %1 = %2;").arg(bcCondition).arg(bcValue);
            boundaryDataR.insert(index + 2, t);
            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_SOLID_SURFACE\";");
            boundaryDataR.insert(index + 2, "int bcType = 2;");
        }
        else if (bcType == "VelocityInlet")
        {
            //Turb_ke
            if (isKE == "true")
            {
                paraValue = getParameterGroupValue("epsilonBoundary", "turbE", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double epsilon = %1;").arg(paraValue));

                paraValue = getParameterGroupValue("kineticBoundary", "turbK", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double kinetic = %1;").arg(paraValue));

                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_INLET\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_INLET\";");
            }
            QString t = QString("double %1 = %2;").arg(bcCondition).arg(bcValue);
            boundaryDataR.insert(index + 2, t);
            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_VELOCITY_INLET\";");
            boundaryDataR.insert(index + 2, "int bcType = 5;");
        }
        else if (bcType == "PressureOutlet")
        {
            if (isKE == "true")
            {
                paraValue = getParameterGroupValue("epsilonBoundary", "turbE", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double epsilon = %1;").arg(paraValue));

                paraValue = getParameterGroupValue("kineticBoundary", "turbK", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double kinetic = %1;").arg(paraValue));

                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_PRESSUREOUTLET\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_PRESSUREOUTLET\";");
            }
            QString t = QString("double %1 = %2;").arg(bcCondition).arg(bcValue);
            boundaryDataR.insert(index + 2, t);
            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_PRESSURE_OUTLET\";");
            boundaryDataR.insert(index + 2, "int bcType = 6;");
        }
        else if (bcType == "FixTWall")
        {
            if (isKE == "true")
            {
                paraValue = getParameterGroupValue("epsilonBoundary", "turbE", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double epsilon = %1;").arg(paraValue));

                paraValue = getParameterGroupValue("kineticBoundary", "turbK", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double kinetic = %1;").arg(paraValue));

                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_PRESSUREOUTLET\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_PRESSUREOUTLET\";");
            }
            QString t = QString("double %1 = %2;").arg(bcCondition).arg(bcValue);
            boundaryDataR.insert(index + 2, t);
            boundaryDataR.insert(index + 2, "string energyBoundaryType = \"ENERGY_WALL\";");
            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_SOLID_SURFACE\";");
            boundaryDataR.insert(index + 2, "int bcType = 2;");
        }
        else if (bcType == "FixTWall")
        {
            if (isKE == "true")
            {
                paraValue = getParameterGroupValue("epsilonBoundary", "turbE", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double epsilon = %1;").arg(paraValue));

                paraValue = getParameterGroupValue("kineticBoundary", "turbK", d);
                boundaryDataR.insert(index + 2, QStringLiteral("double kinetic = %1;").arg(paraValue));

                boundaryDataR.insert(index + 2, "string epsilonBoundaryType = \"TURB_EPSILON_PRESSUREOUTLET\";");
                boundaryDataR.insert(index + 2, "string kineticBoundaryType = \"TURB_K_PRESSUREOUTLET\";");
            }
            QString t = QString("double %1 = %2;").arg(bcCondition).arg(bcValue);
            boundaryDataR.insert(index + 2, t);
            boundaryDataR.insert(index + 2, "string energyBoundaryType = \" ENERGY_HEAT_FLUX_WALL\";");
            boundaryDataR.insert(index + 2, "string flowType = \"FLOW_SOLID_SURFACE\";");
            boundaryDataR.insert(index + 2, "int bcType = 2;");
        }

        boundaryData = "";
        boundaryData = boundaryDataR.join("\n"); // from QStringList to QString
        boundaryFile.seek(0);
        QTextStream out(&boundaryFile);
        out << boundaryData; //writing to the same file
        boundaryFile.close();
        return true;
    }
    else
    {
        qDebug() << "can not read boundary file!";
        return false;
    }


}

void GetFiles(std::string path, std::vector<std::string>& filenames)
{
    intptr_t hfile = 0;
    struct _finddata_t fileInfo;
    std::string p;
    if ((hfile = _findfirst(p.assign(path).append("\\*").c_str(), &fileInfo)) != -1)
    {
        do
        {
            if ((fileInfo.attrib & _A_SUBDIR))
            {
                if (strcmp(fileInfo.name, ".") != 0 && strcmp(fileInfo.name, "..") != 0)
                    GetFiles(p.assign(path).append(fileInfo.name), filenames);
            }
            else
            {
                filenames.push_back(p.assign(path).append(fileInfo.name));
            }
        } while (_findnext(hfile, &fileInfo) == 0);
        _findclose(hfile);
    }
}
